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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Pattern Title
Expression
^\D?(\d{3})\D?\D?(\d{3})\D?(\d{4})$
Description
This RegEx requires a US phone number WITH area code. It is written to all users to enter whatever delimiters they want or no delimiters at all (i.e. 111-222-3333, or 111.222.3333, or (111) 222-3333, or 1112223333, etc...).
Matches
(111) 222-3333 | 1112223333 | 111-222-3333
Non-Matches
11122223333 | 11112223333 | 11122233333
Author Rating: The rating for this expression. Laurence O'Donnell
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: Oracle statement to parse to components
Name: Stew
Date: 4/29/2020 5:56:19 PM
Comment:
SELECT regexp_substr('(800) 555-1212', '^(\D?(\d{3}))(\D?\D?(\d{3}))(\D?(\d{4}))$', 1, 1, '', 2) AS area_code, regexp_substr('(800) 555-1212', '^(\D?(\d{3}))(\D?\D?(\d{3}))(\D?(\d{4}))$', 1, 1, '', 4) AS phone_exch, regexp_substr('(800) 555-1212', '^(\D?(\d{3}))(\D?\D?(\d{3}))(\D?(\d{4}))$', 1, 1, '', 6) AS last_4 FROM dual


Title: Perfect!
Name: Stew
Date: 4/29/2020 5:54:50 PM
Comment:
Just what I needed, thanks!


Title: Works..sort of
Name: The Bandit
Date: 3/15/2018 6:48:48 PM
Comment:
works as expected however, the '\D' tokens allow for any non-digit characters (such as letters) which we don't necessarily want in phone numbers (or at least in those positions). still give it a 4/5


Title: The BEST
Name: Shiva
Date: 9/14/2013 5:21:57 PM
Comment:
This is just fantastic. Now my regex supports all the widely used phone number formats. Thanks a lot.


Title: The BEST
Name: Shiva
Date: 9/14/2013 5:21:31 PM
Comment:
This is just fantastic. Now my regex supports all the widely used phone number formats. Thanks a lot.


Title: Just works
Name: James
Date: 9/8/2011 5:41:49 PM
Comment:
Just works. the biggest issue with US is the delimiters. dashes, periods, brackets etc. this allows all or none. perfect


Title: Madatory Title Entry
Name: Aaron Kibbie
Date: 10/14/2005 5:30:26 PM
Comment:
Woops, forgot the other 2 digits in the area code *grins sheepishly* ^\D?(^[2-9]\d{2})\D?\D?(\d{3})\D?(\d{4})$


Title: Mandatory Title Entry
Name: Aaron Kibbie
Date: 10/14/2005 5:28:51 PM
Comment:
The only thing I would change is making sure the area code doesn't begin with 0,1 so my change is ^\D?(^[2-9])\D?\D?(\d{3})\D?(\d{4})$


Title: Still learning cont...
Name: Chewie
Date: 9/30/2003 4:03:33 PM
Comment:
Doh! After reading the comments above I completely overlooked entering a single open bracket without a close! Try this: // with brackets pattern1 = /^\(\d{3}\)[ -.]\d{3}[ -.]\d{4}$/; // without brackets pattern2 = /^\d{3}[ -.]\d{3}[ -.]\d{4}$/; if (!pattern1.test(telephone) && !pattern2.test(telephone)) { etc....


Title: Still learning
Name: Chewie
Date: 9/30/2003 3:42:58 PM
Comment:
Try this instead: ^\(?\d{3}\)?[ -.]\d{3}[ -.]\d{4}$ It requires delimiters of a space, a dash or a period. It requires a 3 figure area code followed by the standard 3 figure and 4 figure grouping. It allows optional brackets around the area code. It will not accept any excess numbers like x1425 but if there are no restrictions on this simply remove the $ sign from the end of the expression.


Title: Mr.
Name: Pedram Nimreezi
Date: 5/5/2003 12:54:13 AM
Comment:
(654(294-7654 and (654-294-7654 is a false positive.


Title: Intern
Name: Reuben
Date: 5/3/2003 1:20:40 PM
Comment:
Works great!


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