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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Pattern Title
Expression
^(?:(?:[\+]?(?<CountryCode>[\d]{1,3}(?:[ ]+|[\-.])))?[(]?(?<AreaCode>[\d]{3})[\-/)]?(?:[ ]+)?)?(?<Number>[a-zA-Z2-9][a-zA-Z0-9 \-.]{6,})(?:(?:[ ]+|[xX]|(i:ext[\.]?)){1,2}(?<Ext>[\d]{1,5}))?$
Description
This allows the formatting of most phone numbers.
Matches
1-800-DISCOVER | (610) 310-5555 x5555 | 533-1123
Non-Matches
1 533-1123 | 553334 | 66/12343
Author Rating: The rating for this expression. Nicholas Berardi
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: Split the Exchange and SLN
Name: Sebastian
Date: 11/7/2012 2:50:16 PM
Comment:
How to split the Exchange(YYY) and the SLN(ZZZ) (XXX-YYY-ZZZZ)?


Title: question
Name: John
Date: 12/14/2011 1:10:50 PM
Comment:
Could you explain what the ? stands for before the <Number>


Title: Thanks!
Name: Stanislav
Date: 10/30/2011 3:34:56 PM
Comment:
Nikolas, thanks a lot for the regEx! :)


Title: thanks
Name: paull
Date: 12/1/2010 6:27:38 AM
Comment:
Thanks a lot It is the best pattren for phone numbers


Title: Mr.
Name: Asif
Date: 1/20/2009 7:04:43 AM
Comment:
hey nicholas thanks for ur help.plz send edits for ur regular expression bcz i want to verify this tel:+1-202-456-1111;ext=222 plz reply hurriedly..


Title: Mr
Name: Balachandar
Date: 9/28/2006 2:13:50 AM
Comment:
It is the best suitable pattren for international phone numbers


Title: Filter out letters
Name: Beginner Gakusei
Date: 1/6/2005 5:37:30 AM
Comment:
This is a very nice regex. I dont know how to make regex so can u please tell me how I can edit this code so that letters are not accepted? Many thanks. =)


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