Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $patternName = '/(?<name>[a-zA-Z0-9]+)([!@#$?]+)/';
- $pattern = '/^(?<name>[a-zA-Z0-9!@#$?]+)(=(?<length>[0-9]+))(<<(?<geocode>.*))/m';
- $arr = [];
- while (true) {
- $input = readline();
- if ($input === 'Last note') {
- break;
- }
- if (preg_match($pattern, $input)) {
- preg_match_all($pattern, $input, $matchesLG, PREG_SET_ORDER, 0);
- $length = $matchesLG[0]["length"];
- $geocode = $matchesLG[0]["geocode"];
- $longName = $matchesLG[0]["name"];
- $name = "";
- preg_match_all($patternName, $longName, $matchesName, PREG_SET_ORDER, 0);
- foreach ($matchesName as $nameParts) {
- $name .= $nameParts["name"];
- }
- if (strlen($geocode) == $length) {
- echo "Coordinates found! $name -> $geocode\n";
- } else {
- echo "Nothing found!\n";
- }
- } else {
- echo "Nothing found!\n";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement