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[1-9]\d{1}\s\d{4}\s?\d{4}$)|(^0[1-9]\d{2}\s\d{3}\s?\d{4}$)|(^0[1-9]\d{2}\s\d{4}\s?\d{3}$)|(^0[1-9]\d{3}\s\d{3}\s?\d{2}$)|(^0[1-9]\d{3}\s\d{3}\s?\d{3}$)|(^0[1-9]\d{4}\s\d{3}\s?\d{2}$)|(^0[1-9]\d{4}\s\d{2}\s?\d{3}$)|(^0[1-9]\d{4}\s\d{2}\s?\d{2}$)
Description
This will match valid UK telephone numbers. This adheres to ofcom's code and number length guide available at http://www.ofcom.org.uk/licensing_numbering/numbers/num_user_guide#1b Brackets and international codes are not allowed. A space MUST be used after the dialling code, and spaces at the expected points within the remainder of the number can be used if need be, but not nessesary, hence 0208 6473 373 is the same as 0208 647 3373 and 0208 6473373
Matches
01323 293 374 | 020 73643763 | 017354 7478
Non-Matches
02 83838 74 | (01323) 828223 | +44 88282 828
Author Rating: The rating for this expression. rob collyer
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: Inefficient pattern.
Name: g1smd
Date: 8/4/2012 2:14:05 PM
Comment:
This pattern is very inefficient. Once the start ^0[1-9]\d{1}\s\ has been found, there is no need to repeat it again and again in the pattern within the OR part. Just the remaining digits need to be ORd. Note too that London numbers are 020 Nnnn nnnn where N can be 0, 1, 3, 7 or 8.


Title: please make it so that spaces are optional not mandatory!
Name: Oli
Date: 6/6/2012 6:03:38 AM
Comment:
Brilliant Regex.. however, please make it so that users do not have to put a space.. eg 019********


Title: Wouldn't work with php but does with JavaScript
Name: Adam
Date: 3/9/2008 7:58:45 PM
Comment:
Tried using this in a validation function on a form using php and it didn't worj but did using JavaScript......odd


Title: Respec'
Name: Jezza
Date: 11/29/2005 7:11:29 AM
Comment:
Thanks for this, and you deserve lots of big presents for Christmas.


Title: Excellent!
Name: Neil Parker
Date: 11/11/2004 8:23:31 AM
Comment:
Fantastic resource, saved me hours and hours of work. Thanks


Title: Parse Error in ASP.Net
Name: Jodda - UK
Date: 7/23/2004 6:46:02 AM
Comment:
Too many )'s


Title: Nice one!
Name: Stu Rayner
Date: 7/8/2004 10:12:42 AM
Comment:
Very good, but would have liked to allow the inclusion of brackets. Probably not hard to amend it to do this, though.


Title: Works for me!!! Thanx
Name: Tom Jones
Date: 7/1/2004 9:11:08 AM
Comment:
Seems to work well.... still testing though. Best one I've seen so far when you dont need extension numbers, international stuff or brackets. I'm doing a UK app, for UK people, so this was perfect!


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