Skip to content

Instantly share code, notes, and snippets.

@FCO
Last active September 13, 2018 23:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FCO/458b6fef51ebd357ec80f03a77c2ef9a to your computer and use it in GitHub Desktop.
Save FCO/458b6fef51ebd357ec80f03a77c2ef9a to your computer and use it in GitHub Desktop.
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