Displaying page
of
pages;
Items to
Title |
Test
Details
US Phone with/without Extension (.NET)
|
Expression |
\(?(\d{3})(?:\)*|\)\s*-*|\.*|\s*|/*|)(\d{3})(?:\)*|-*|\.*|\s*|/*|)(\d{4})(?:\s?|,\s?)
|
Description |
Fairly universal regex for matching any US Phone number in .net. It basically matches the 10 digit phone number using the common US patterns, and allows for any text after the fact. I use it with the .replace method and pull out "$1$2$3" to get the pure 10-digit phone number, and anything after that is just stored as additional text. this additional text could be an extension, daytime information, hours, etc.
|
Matches |
9405551234, (940) 555-1234, 940.555.1234, 940-555-1234, 940-555-1234 x5000, 940-555-1234, ext. 5000, 940-555-1234 8-5pm
|
Non-Matches |
94055512345, 9401-546-5468, or any other non-10-digit, non-standard pattern
|
Author |
Rating:
Not yet rated.
Jorin Slaybaugh
|
Displaying page
of
pages;
Items to