Last active
February 8, 2016 08:24
-
-
Save ctorgalson/3763300 to your computer and use it in GitHub Desktop.
North American Phone Number 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
// This pattern matches the phone numbers ONLY (i.e. it does NOT match the | |
// extension or text) in: | |
// | |
// 250-370-8517 or toll free 1-888-370-8517 | |
// 250 370 8517 or toll free 1 888 3708517 | |
// 250 370 8517 or toll free 18883708517 | |
// 604-851-4700 Ext. 646170 | |
// +12503708517 | |
// 1.250.370.8517 | |
// (250) 370-8517 | |
// | |
// It's probably possible to fool it in any case (by using weird delimiter | |
// characters, for example): | |
var pattern = /\+?(\d)?[ \.-]?(\(?\d{3}\)?)[ \.-]?(\d{3})[ \.-]?(\d{4})/g; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment