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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find A Forgiving US Phone Number
Expression
^(1?)(-| ?)(\()?([0-9]{3})(\)|-| |\)-|\) )?([0-9]{3})(-| )?([0-9]{4}|[0-9]{4})$
Description
This is a fairly forgiving phone number match. It's original purpose was to extract phone numbers from the details field in our database and into their own phone number table. It worked brilliantly. Enjoy!
Matches
14165551212, 4165551212, (416)5551212, 416 555 1212, 416-555-1212, (416)-555-1212, (416) 555 1212, 1-900-888-1212
Non-Matches
456-444-45464, 416-SEX-POOP, 4!6-777-#232
Author Rating: The rating for this expression. Doug Jones
Source KishCom Inc.
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: minor modification
Name: Gady
Date: 10/4/2011 9:19:50 AM
Comment:
This modification allows dashes anywhere in the phone number: /^(1?)(-| ?)(\()?((?:[0-9]-?){3})(\)|-| |\)-|\) )?((?:[0-9]-?){3})(-| )?((?:[0-9]-?){4}|(?:[0-9]-?){4})$/


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