RegExLib.com - The first Regular Expression Library on the Web!

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

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
Bad Good

Enter New Comment

Title
 
Name
 
Comment
 
Spammers suck - we apologize. Please enter the text shown below to enable your comment (not case sensitive - try as many times as you need to if the first ones are too hard):

Existing User Comments

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})?$/";


Copyright © 2001-2024, RegexAdvice.com | ASP.NET Tutorials