Title |
Test
Find
A Forgiving US Phone Number
|
Expression |
^(1?)(-| ?)(\()?([0-9]{3})(\)|-| |\)-|\) )?([0-9]{3})(-| )?([0-9]{4}|[0-9]{4})$ |
Description |
This is a fairly forgiving phone number match. It's original purpose was to extract phone numbers from the details field in our database and into their own phone number table. It worked brilliantly. Enjoy! |
Matches |
14165551212, 4165551212, (416)5551212, 416 555 1212, 416-555-1212, (416)-555-1212, (416) 555 1212, 1-900-888-1212 |
Non-Matches |
456-444-45464, 416-SEX-POOP, 4!6-777-#232 |
Author |
Rating:
Doug Jones
|
Source |
KishCom Inc. |
Your Rating |
|
Title: minor modification
Name: Gady
Date: 10/4/2011 9:19:50 AM
Comment:
This modification allows dashes anywhere in the phone number:
/^(1?)(-| ?)(\()?((?:[0-9]-?){3})(\)|-| |\)-|\) )?((?:[0-9]-?){3})(-| )?((?:[0-9]-?){4}|(?:[0-9]-?){4})$/