Title |
Test
Find
Pattern Title
|
Expression |
^[\\(]{0,1}([0-9]){3}[\\)]{0,1}[ ]?([^0-1]){1}([0-9]){2}[ ]?[-]?[ ]?([0-9]){4}[ ]*((x){0,1}([0-9]){1,5}){0,1}$ |
Description |
US Telephone Number where this is regular expression excludes the first number, after the area code,from being 0 or 1; it also allows an extension
to be added where it does not have to be prefixed by 'x'. |
Matches |
(910)456-7890 | (910)456-8970 x12 | (910)456-8970 1211 |
Non-Matches |
(910) 156-7890 | (910) 056-7890 | (910) 556-7890 x |
Author |
Rating:
Not yet rated.
Bill Anderson
|
Source |
|
Your Rating |
|
Title: Thank you
Name: Michael Cannon
Date: 4/24/2004 12:49:45 AM
Comment:
I used this, but cleaned it up slightly to prevent alpha characters in the leading 2nd set of numbers. You can still have mismatched (), but I'm not so worried about that.
$telRegex = "/^[\\(]?([0-9]){3}[\\)]?[ -]?([1-9]){1}([0-9]){2}-([0-9]){4}( x?([0-9]){1,5})?$/";