Created
March 23, 2017 19:55
-
-
Save rgbink/1aa98efbe3cee294d2e584fd89722717 to your computer and use it in GitHub Desktop.
Fairly robust phone validation regex
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
// 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