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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Phone Numbers
Expression
^(1\s*[-\/\.]?)?(\((\d{3})\)|(\d{3}))\s*[-\/\.]?\s*(\d{3})\s*[-\/\.]?\s*(\d{4})\s*(([xX]|[eE][xX][tT])\.?\s*(\d+))*$
Description
This regular expressions matches phone numbers with area codes and optional US country code and optional phone extension. User have so many ways of entering phone numbers into input fields. This allows for some of the ones I've encountered. Feel free to contact me if you find ones that do not match.
Matches
2405525009 | 1(240) 652-5009 | 240/752-5009 ext.55
Non-Matches
(2405525009 | 2 (240) 652-5009
Author Rating: The rating for this expression. Dean Dal Bozzo
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: Very good
Name: Jax
Date: 3/24/2015 7:26:33 AM
Comment:
Thanks for the great regex, built on it a little but works great! just a heads up for future development it does not recognise the follow: - Spaces between digits (some people break up into common formats such as 01784 1...) - hyphen between the numbers (Netherlands). Otherwise great 5 stars from me!


Title: Regex for Fax
Name: Pankaj
Date: 5/17/2011 6:48:47 AM
Comment:
hello i want a regular expression for fax which accepts numerics,space,"-","()","+".Can u plz provide it


Title: Slightly improved
Name: Kevin
Date: 1/12/2010 11:36:41 AM
Comment:
I added the +1 option, fixed a bug with the hyphen between the 1 and the area code, and made the extensions more flexible. ^(1\s*[-\/\.]?\s*)?(\((\d{3})\)|(\d{3}))\s*[-\/\.]?\s*(\d{3})\s*[-\/\.]?\s*(\d{4})\s*(([xX]|[eE][xX][tT]?)\.?\s*([#*\d]+))*$


Title: only digits???
Name: Bodia Soryformyenglish:)
Date: 11/28/2009 12:44:44 PM
Comment:
Please add to Matches number "one-one-one";)


Title: optional area codes
Name: Mtimdog
Date: 3/10/2004 2:21:57 PM
Comment:
Does not accept numbers without area code like 333-4444.... Fixed by adding (....stuff for 1(333) areacode....)? to it


Title: '+1'
Name: Harley
Date: 11/11/2003 9:15:22 PM
Comment:
Does not accept numbers with a + in front of the 1 (as is customary for international codes), such as: +1 987 654 3210 Easily fixed with the addition of a \+? just before the 1. Thanks for a great RE!


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