Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $input = intval(readline());
- $regexFirst = '/(^[$|%]{1})([A-Z]{1}[a-z]{2,})([$|%]{1})/';
- $regexSecond = '/([^\$%\]\[\|]+)/';
- for ($d = 0; $d < $input; $d++) {
- $args = explode(': ', readline());
- $wordFirst = preg_match($regexFirst, $args[0], $matchWord);
- $wordSecond = preg_match_all($regexSecond, $args[1], $matchWordS);
- if (preg_match($regexFirst, $args[0], $matchWord)
- && $matchWord[1] == $matchWord[3] && count($matchWordS[0]) == 3) {
- $tag = $matchWord[2];
- $decryptedMessage = '';
- for ($i = 0; $i < count($matchWordS[0]); $i++) {
- $decryptedMessage .= chr($matchWordS[0][$i]);
- }
- echo "{$tag}: {$decryptedMessage}\n";
- } else {
- echo "Valid message not found!" . PHP_EOL;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement