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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Pattern Title
Expression
(\s*\(?0\d{4}\)?(\s*|-)\d{3}(\s*|-)\d{3}\s*)|(\s*\(?0\d{3}\)?(\s*|-)\d{3}(\s*|-)\d{4}\s*)|(\s*(7|8)(\d{7}|\d{3}(\-|\s{1})\d{4})\s*)
Description
another uk telephone number regex. This was adapted from another on this site http://www.regexlib.com/REDetails.aspx?regexp_id=297 I added support for hyphens and for london shorthand numbers ie. 8234-1234 72341234 Still want to be permissive where possible....Still need to sort out the all zeros, also not sure if numbers with 4 digits followed by 7 used in london 0208-234-1234 is the area of the uk where this occurs, or all areas outside of london are in format 5 digits followed by 6 digits ie. 01608 123456. If that is the case for the 4-7 pattern only 0208 or 0207 could be enforced.
Matches
0208 993 5689 | 0208-993-5689 | 89935689
Non-Matches
1608 123 456
Author Rating: Not yet rated. Matt Baskey
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: Doesn't match many of the numbers which should be valid.
Name: g1smd
Date: 8/3/2012 7:51:25 PM
Comment:
** london 0208-234-1234 ** London numbers are NEVER this format. Area codes beginning 02 are always 2+8 format numbers, e.g. 020 3000 8888. ** areas outside of london are in format 5 digits followed by 6 digits ie. 01608 123456 ** No. A variety of formats are in use. They include 2+8, 3+7, 4+6, 4+5, 5+5, 5+4 format for geographic numbers and 0+10, 0+9, 0+7 format for non-geographic numbers. This pattern is totally inadequate to match those. Additionally, the user should be allowed to input numbers in any format they like, and the system set up to check the number range is valid and the number of digits is correct for the number range, using a second tier of RegEx patterns. One other tip for efficient RegEx patterns is, having found the leading 0 once don't search for it again. (^0....$)|(^0....$) simplifies to ^0(....|....)$ etc.


Title: Doesn't match many of the numbers which should be valid.
Name: g1smd
Date: 8/3/2012 7:51:11 PM
Comment:
** london 0208-234-1234 ** London numbers are NEVER this format. Area codes beginning 02 are always 2+8 format numbers, e.g. 020 3000 8888. ** areas outside of london are in format 5 digits followed by 6 digits ie. 01608 123456 ** No. A variety of formats are in use. They include 2+8, 3+7, 4+6, 4+5, 5+5, 5+4 format for geographic numbers and 0+10, 0+9, 0+7 format for non-geographic numbers. This pattern is totally inadequate to match those. Additionally, the user should be allowed to input numbers in any format they like, and the system set up to check the number range is valid and the number of digits is correct for the number range, using a second tier of RegEx patterns. One other tip for efficient RegEx patterns is, having found the leading 0 once don't search for it again. (^0....$)|(^0....$) simplifies to ^0(....|....)$ etc.


Title: stupid.
Name: oli
Date: 6/6/2012 6:25:08 AM
Comment:
says that 01903 7866643285872894 is valid.. these are so basic things.. also in england when we put +44 we remove the 0.. so +441234 567890 should work.


Title: doesnt support +44
Name: oli
Date: 6/6/2012 5:59:59 AM
Comment:
no +44 support?? :S


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