Title |
Test
Find
International & Domestic Phone Numbers with Ext
|
Expression |
^([\+][0-9]{1,3}([ \.\-])?)?([\(]{1}[0-9]{3}[\)])?([0-9A-Z \.\-]{1,32})((x|ext|extension)?[0-9]{1,4}?)$ |
Description |
Somewhat conservative expression for evaluating phone numbers. Based off ideas found at http://stackoverflow.com/questions/123559/a-comprehensive-regex-for-phone-number-validation this allows country codes, with or without the + symbol, area codes surrounded by parenthesis (or not) and numbers delimited by spaces, periods or dashes. You'll want to independently test for string length based on your needs. |
Matches |
(123)456-7890 | (123)456-7890 x123 | +1 (123)456-7890 | 12 3456 789 0 x1234 | (123)456-7890x123 |(123)456-7890ext123 | (123)456-7890 extension123 | 123.456.7890 | 1234567890 | 1234567 | 12 34 56 78 90 | 12 3 4567 890123 x4567 | +12 3456 7890 | +12 34 56 7890 | +12 3456 7890 | +12 34567890 |
Non-Matches |
(123)456-7890 x 123 | 123.45.6.78+90 |
Author |
Rating:
Not yet rated.
Brent Thomas
|
Source |
http://stackoverflow.com/questions/123559/a-comprehensive-regex-for-phone-number-validation + Hacking |
Your Rating |
|
Title: Matches correction
Name: Sharon
Date: 2/5/2019 7:38:25 AM
Comment:
In your Matches section +1 (123)456-7890 is not matching with ur regex instead
+1 (123) 456-7890 is working fine which is correct too. You may want to update it.
Thanks
Title: Matches correction
Name: Sharon
Date: 2/5/2019 7:38:12 AM
Comment:
In your Matches section +1 (123)456-7890 is not matching with ur regex instead
+1 (123) 456-7890 is working fine which is correct too. You may want to update it.
Thanks
Title: Extension-space non-match?
Name: Jarod
Date: 1/10/2014 12:18:29 PM
Comment:
While I didn't read all of the lengthy article on Stackoverflow, why is a space after the "x" cause for a non-match?