Skip to content

Instantly share code, notes, and snippets.

@NoraCodes
Created April 26, 2017 17:25
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 NoraCodes/16da8b43ee21d230165ad023c6c6a229 to your computer and use it in GitHub Desktop.
Save NoraCodes/16da8b43ee21d230165ad023c6c6a229 to your computer and use it in GitHub Desktop.
Some Regular Expressions
Phone numbers:
(\+[0-9]{1,3}[. -/])?\(?[0-9]{3}\)?[. -/][0-9]{3}[. -/][0-9]{4}
1 2 3 4
Explaination:
1: (\+[0-9]{1,3}[. -/])? matches a country code like +1 or +999, and seperator
2: ?\(?[0-9]{3}\)? matches an area code with or without parentheses, like 858 or (858), and seperator
3: [0-9]{3}[. -/] matches an exchange number, and seperator
4: [0-9]{4} matches a 4-digit flop number
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment