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*\(?(020[7,8]{1}\)?[ ]?[1-9]{1}[0-9{2}[ ]?[0-9]{4})|(0[1-8]{1}[0-9]{3}\)?[ ]?[1-9]{1}[0-9]{2}[ ]?[0-9]{3})\s*$
Description
Matches UK phone numbers - London and regional. It started off with something fairly short posted by liljim at www.forums.devshed.com but I wanted a little more precision to weed out all the zeros. Now it also weeds out premium phone numbers (as of 19/12/03).
Matches
02071111111 | 01000100000
Non-Matches
00000000000
Author Rating: The rating for this expression. M h
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: Incorrect and inefficient syntax; pattern doesn't match all that it should.
Name: g1smd
Date: 8/4/2012 2:01:42 PM
Comment:
020[7,8]{1} is incorrect syntax. The comma is an error; telephone numbers do not include commas. The {1} is redundant. The pattern should not be matching just 020[78] here. London uses more ranges than that. The pattern should be matching 020[01378]. It should also match other 2+8 format numbers such as 023[0189], 024[017], 028[012346789] and 029[012]. The [ ]? should be \s? here. The [1-9]{1} should be [1-9] here. The [1-8]{1} should be [1-8] here. The pattern (0[1-8]{1}[0-9]{3}\)?[ ]?[1-9]{1}[0-9]{2}[ ]?[0-9]{3}) is completely inadequate. It suggests that area codes run from 01000 to 08999 and all such numbers are 4+6 format and the local number part must begin with only 1 to 9. This is far short of reality. The UK does have numbers beginning 09 for premium rate. Geographic numbers are a mix of 2+8, 3+7, 4+6, 4+5, 5+5, 5+4 format, and non-geographic numbers are a mix of 0+10, 0+9, 0+7 format. The pattern completely ignores all of those and is unusable.


Title: RegEx for all UK formats.
Name: g1smd
Date: 7/27/2012 4:21:15 AM
Comment:
This pattern copes with numbers beginning 011, 00 or + with 44 country code or with 0 trunk prefix, either of which is followed by area code and phone number. It copes with UK numbers in 2+8, 3+7, 4+6, 4+5, 5+5, 5+4 and 3+6 format. The pattern was used in Java hence the double escaping. "^(?:(?:(?:0(?:0\\s?|11\\s)|\\+)44\\s?(?:\\(?0\\)?\\s?)?)|(?:\\(?0))(?:(?:\\d{5}\\)?\\s?\\d{4,5})|(?:\\d{4}\\)?\\s?(?:\\d{5}|\\d{3}\\s?\\d{3}))|(?:\\d{3}\\)?\\s?\\d{3}\\s?\\d{3,4})|(?:\\d{2}\\)?\\s?\\d{4}\\s?\\d{4}))(?:\\s?\\#\\d{3,4})?$" Once the phone number has been detected, it is important to then tidy it up and show it with the spacing corrected per number type. That process requires at least 7 more, much simpler, RegEx patterns, detailed elsewhere.


Title: What about 118118!! UK Phone numbers
Name: Nicholas John Joseph Taylor
Date: 3/21/2012 9:08:09 PM
Comment:
^(((\+44 \(0\) )|(0|1))|\(0)( |\(|\-){0,2}([0-9]( |\(|\)|\-){0,2}){5,10}$


Title: UK Telephone number
Name: Nicholas John Joseph Taylor
Date: 3/21/2012 8:59:00 PM
Comment:
I needed to come up with a quick regex for validating UK Telephone numbers. It works well and simply on the basis that it will allow all valid UK numbers and although it allows some silly things in there, the number will be legible by the reader. I code in C, so the slashes have been escaped: ^(((\\+44 \\(0\\) )|0)|\\(0)( |\\(|\\-){0,2}([0-9]( |\\(|\\)|\\-){0,2}){9,10}$ actual regex ^(((\+44 \(0\) )|0)|\(0)( |\(|\-){0,2}([0-9]( |\(|\)|\-){0,2}){9,10}$ Simple eh? But good!


Title: UK Telephone number
Name: Nicholas Taylor
Date: 3/21/2012 8:57:13 PM
Comment:
I needed to come up with a quick regex for validating UK Telephone numbers. It works well and simply on the basis that it will allow all valid UK numbers and although it allows some silly things in there, the number will be legible by the reader. I code in C, so the slashes have been escaped: ^(((\\+44 \\(0\\) )|0)|\\(0)( |\\(|\\-){0,2}([0-9]( |\\(|\\)|\\-){0,2}){9,10}$ actual regex ^(((\+44 \(0\) )|0)|\(0)( |\(|\-){0,2}([0-9]( |\(|\)|\-){0,2}){9,10}$ Simple eh? But good!


Title: UK system has multiple formats.
Name: Steve.
Date: 11/4/2011 4:00:50 PM
Comment:
Most UK telephone numbers can have either 9 or 10 digits after the 0 trunk prefix. The initial 0 is omitted when calling from abroad. 01 and 02 area codes should have parentheses around them if the local number part does not begin with a 0 or 1. 01 and 02 area codes do not have parentheses around them if the local number part begins with a 0 or 1. These are National Dialling Only ranges. All other area codes do not have parentheses around them as the area code is required for all calls. Number formats are expressed as: 2+8 to represent (02x) xxxx xxxx [in 5 areas] or 05x xxxx xxxx or 070 xxxx xxxx or 076 xxxx xxxx. 3+7 to represent (011x) xxx xxxx [in 6 areas] or (01x1) xxx xxxx [in 6 areas] or 03xx xxx xxxx or 08xx xxx xxxx or 0800 xxx xxxx or 09xx xxx xxxx. 3+6 to represent 0500 xxxxxx or 0800 xxxxxx. 4+6 to represent (01xxx) xxxxxx [in 580 areas] or 07xxx xxxxxx. 4+5 to represent (01xxx) xxxxx [in 41 areas]. 5+5 to represent (01xx xx) xxxxx [in 12 areas]. 5+4 to represent (01xx xx) xxxx [in 1 area]. Valid formats include: (011x) - 3+7. (01x1) - 3+7. (01xxx) - 4+6 or 4+5. (01xx xx) - 5+5 or 5+4. (02x) - 2+8. 03xx - 3+7. 05x - 2+8. 0500 - 3+6. 07xxx - 4+6. 070 - 2+8. 076 - 2+8. 08xx - 3+7. 0800 - 3+7 or 3+6. 09xx - 3+7. There are a small number of exceptions such as 0800 1111 and 0845 4647. The UK system is quite complex!


Title: Phone no
Name: Rajaraman
Date: 5/28/2008 9:23:44 AM
Comment:
hi :- How to validate india mobile phone no in asp.net.. dont tell regular expression.


Title: Nope
Name: Andy
Date: 5/13/2008 2:26:35 AM
Comment:
Have tried many UK phone numbers that simply do not work. Working in Bristol the first thing I did was try Bristol phone numbers and they don't work. If a major cities phone numbers don;t work then... RegX for UK phone numbers seems to be a real headache for everyone. Thanks BT!


Title: London numbers don't work with spaces.
Name: Mark
Date: 11/19/2007 9:56:11 AM
Comment:
Doesn't seem to cope with London numbers very well if used with spaces e.g. 020 8### #### or 0208 ### #### don't work but everybody uses spaces when entering phone numbers in on-line forms. Take the spaces out and it works. Some other regional numbers I tested seem to work OK with or without spaces.


Title: New Area Codes and London Format
Name: Illarane
Date: 10/10/2006 11:43:06 PM
Comment:
The format of this is actually incorrect. London phone numbers should be formatted as per ^(\(?020\)?)?[ ]?[3,7,8]{1}[1-9]{1}[0-9]{2}[ \-]?[0-9]{4}$ and not (\(?020[7,8]{1}\)?)?[ ]?[1-9]{1}[0-9]{2}[ ]?[0-9]{4} as the regex above implies. Also, that expression does not account for the new (020) 3 combination which has recently come into being in the Croydon area. I suggest ((\(?020\)?[ ]?)?[3,7,8]{1}[1-9]{1}[0-9]{2}[ \-]?[0-9]{4}|(\(?0[1-8]{1}[0-9]{3}\)?[ ]?)?[1-9]{1}[0-9]{2}[ ]?[0-9]{3}) as a partial improvement on this, since it allows for the new London codes and only accepts them either as either a string of 11 numbers or if they're correctly formatted. It still needs some work, but it's a good start.


Title: Whoops! - Yes it does
Name: John
Date: 11/25/2004 5:52:03 PM
Comment:
Sorry


Title: Ten digits not catered for
Name: John
Date: 11/25/2004 5:48:22 PM
Comment:
doesn't take account of ten digit phone numbers (e.g. St Austell, Cornwall; Bodmin, Cornwall)


Title: Actual Allowed UK No. Format
Name: md
Date: 3/17/2004 6:17:04 AM
Comment:
Area code and number lengths currently diallable within the UK: Area Code: Local No. Length: Example: 02X 8 (029) XXXX XXXX 01XX 7 (0151) XXX XXXX 01XXX 5 (01204) XXXXX 01XXX 6 (01865) XXXXXX 01XXXX 5 (015396) XXXXX 01XXXX 4 (016977) XXXX Local numbers in geographic areas typically start with any digits except `0', `1' or `99'. I'm working on a regex to do this.


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