Last active
September 13, 2018 23:12
-
-
Save FCO/458b6fef51ebd357ec80f03a77c2ef9a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
grammar Phone { | |
token sep { | |
<[.-]> | |
} | |
token phone { | |
<?after [^|\s]> [\d <.sep>]? [\d ** 3] ** 2 % <.sep> <.sep> \d ** 4 | |
} | |
regex TOP { | |
[.*?<phone>+.*?]* | |
} | |
} | |
say Phone.parse: "Phone numbers 917.234.5678, 1-526-553-1234, 1.917.123.4567 or FAIL > 0.0.0.000.000.00000, 1..111.111.1111 , 22-222-222-2222 , 52-14-54" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment