Skip to content

Instantly share code, notes, and snippets.

@rgbink
Created March 23, 2017 19:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rgbink/1aa98efbe3cee294d2e584fd89722717 to your computer and use it in GitHub Desktop.
Save rgbink/1aa98efbe3cee294d2e584fd89722717 to your computer and use it in GitHub Desktop.
Fairly robust phone validation regex
// basic US, no country code
((\(*\d{3}\)* *?)|(\d{3}[ -\.]*))?\d{3}[ -\.]*\d{4}
// leading country codes and optional repeat separators
^\s*(?:\+?(\d{1,3}))?[-. (]*(\d{3})[-. \/)]*(\d{3})[-. ]*(\d{4})(?: *x(\d+))?\s*$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment