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\d\)?)?( |-|\.)?\d\d\d( |-|\.)?\d{4,4}(( |-|\.)?[ext\.]+ ?\d+)?$
Description
Basic US phone number matching pattern. I found this place and used a regex, so figured I'd share.
Matches
(888) 555-1212 | 888.555.1212 | (888) 555.1212 ext. 1212
Non-Matches
(800) got-fish | 011+ 78907 2344323
Author Rating: Not yet rated. Jon Stephens
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: Tried all US RegExp phone options on this site. This is the best.
Name: Mark
Date: 10/7/2016 7:29:37 PM
Comment:
Tried all US RegExp phone options on this site. This is the best. This one does the best job of limiting to 10 characters while permitting (and limiting to) normal punctuation and allowing optional extensions


Title: phone reg expression
Name: Nancy Chipko
Date: 10/6/2006 2:08:53 PM
Comment:
Great example but don't forget to put in the "/" char in front and back.


Title: Simplified
Name: Bill R.
Date: 10/4/2006 11:19:17 AM
Comment:
^(\(?\d{3}\)?)?( |-|\.)?\d{3}( |-|\.)?\d{4,4}((|-|\.)?[ext\.]+ ?\d+)?$ or for the US.. /^(\(?[1-9]{1}\d{2}\)?)?( |-|\.)?\d{3}( |-|\.)?\d{4,4}(( |-|\.)?[ext\.]+ ?\d+)?$/


Title: Thanks
Name: Brendan
Date: 2/4/2004 9:13:27 PM
Comment:
This site is great it has been so helpful to me and really helped me better understand regular expressions. Thanks everyone.


Title: US Phone Val
Name: Jay Solomon
Date: 12/1/2003 2:28:08 PM
Comment:
I would change it to this for USA validation ^(\(?[1-9]{1}\d\d\)?)?( |-|\.)?\d\d\d( |-|\.)?\d{4,4}(( |-|\.)?[ext\.]+ ?\d+)?$ notice [1-9]{1} this makes sure that the first digit is any number 1-9 and not 000


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