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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Pattern Title
Expression
^(\(?\+?[0-9]*\)?)?[0-9_\- \(\)]*$
Description
A regular expression to match phone numbers, allowing for an international dialing code at the start and hyphenation and spaces that are sometimes entered.
Matches
(+44)(0)20-12341234 | 02012341234 | +44 (0) 1234-1234
Non-Matches
(44+)020-12341234 | 12341234(+020)
Author Rating: The rating for this expression. James Burton
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: comment
Name: name
Date: 6/16/2012 5:14:41 PM
Comment:
this regex matches: (23-123 23--123 and many more...


Title: a small problem
Name: BuKToP
Date: 2/20/2012 5:26:27 PM
Comment:
It should not allow something like: +359(1 234567890


Title: a small problem
Name: BuKToP
Date: 2/20/2012 5:24:13 PM
Comment:
It should not allow something like: +359(1 234567890


Title: if you wanted to add extension support
Name: jimasp
Date: 11/10/2011 9:00:17 AM
Comment:
Can be updated to support extensions like this: ^(\(?\+?[0-9]*\)?)?[0-9\- \(\)]{10,}?([ext]+?[0-9]{3,})?$ This would allow, e.g: +44 (0)123-456-789 x555 0123 456789 ext1234


Title: Doesn't require any numbers
Name: Josh Olson
Date: 12/1/2009 12:24:18 PM
Comment:
It matches (.


Title: Fix for spaces
Name: FokeyJoe
Date: 6/17/2009 12:37:02 PM
Comment:
I think this is a rough fix for the spaces issue that previous commenters have observed (will at least give a positive match, but you'll want to do something else if you're picking bits out of it). ^(\(?\+?[0-9]*\)?)?([0-9\-\(\)]|\s)*$


Title: Very Universal
Name: Dooza
Date: 2/18/2009 4:42:18 AM
Comment:
Does exactly what I was trying to do! Thank you.


Title: Universal
Name: Maxim
Date: 2/25/2008 3:23:37 PM
Comment:
Best for universal phone format!


Title: warning
Name: jam - mark
Date: 3/1/2004 10:05:14 AM
Comment:
Hi, I also had this warning but did as Paul and removed the space... however now, the expression doesnt evaluate correctly giving a true for a correct telephone number when there are spaces within the string. Any ideas on how to fix this?


Title: Warning
Name: Paul
Date: 1/2/2004 2:04:38 PM
Comment:
Sue, I found that by removing the space between \- & \( resolves the warning. So then the pattern becomes: ^(\(?\+?[0-9]*\)?)?[0-9_\-\(\)]*$


Title: Warning
Name: Sue
Date: 10/28/2003 8:06:50 AM
Comment:
I get the warning Warning: ereg(): REG_ERANGE when I use this - cannot find out what it means or how to get rid of it


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