- The first Regular Expression Library on the Web!

Please support RegExLib Sponsors


Regular Expression Details

Title Test Find Pattern Title
^(\(?\+?[0-9]*\)?)?[0-9_\- \(\)]*$
A regular expression to match phone numbers, allowing for an international dialing code at the start and hyphenation and spaces that are sometimes entered.
(+44)(0)20-12341234 | 02012341234 | +44 (0) 1234-1234
(44+)020-12341234 | 12341234(+020)
Author Rating: The rating for this expression. James Burton
Your Rating
Bad Good

Enter New 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
this regex matches: (23-123 23--123 and many more...

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

Title: a small problem
Name: BuKToP
Date: 2/20/2012 5:24:13 PM
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
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
It matches (.

Title: Fix for spaces
Name: FokeyJoe
Date: 6/17/2009 12:37:02 PM
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
Does exactly what I was trying to do! Thank you.

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

Title: warning
Name: jam - mark
Date: 3/1/2004 10:05:14 AM
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
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
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-2021, | ASP.NET Tutorials