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{6}\s*)|(\s*\(?0\d{3}\)?\s*\d{3}\s*\d{4}\s*)
Description
UK Phone Number Allows leading and trailing spaces and optional spaces after the dialing code. Initially the expression I posted was \s*0\d{4}\s*\d{6}\s*|\s*0\d{3}\s*\d{7}\s* But this didn't include optional brackets e.g. (01603) 123123 or phone numbers in a London format e.g. 0208 123 1234
Matches
01603 123123 | 0207 1234567 | (0208) 123 1234
Non-Matches
123 123132
Author Rating: The rating for this expression. Joe Gass
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: Well done for having a go...
Name: Friendface
Date: 7/3/2013 12:26:20 PM
Comment:
...but doesn't match for 5 digits e.g. Newbury Racecourse 01635 40015


Title: Bollocks!
Name: Pissed Off!
Date: 1/2/2010 7:41:51 PM
Comment:
What does it take to get a site admin to remove the earlier duplicates with typos, keeping just the final version?


Title: UK Telephone Number Formats in 2009.
Name: Steve
Date: 12/25/2009 8:33:07 AM
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. 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. 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: How do you contact the site admin?
Name: How do you contact the site admin?
Date: 12/10/2009 8:18:44 PM
Comment:
How do you contact the site admin?


Title: UK Telephone Number Formats in 2009.
Name: Steve
Date: 12/10/2009 5:50:33 PM
Comment:
<p>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. </p><p>01 and 02 area codes should have parentheses around them if the local number part does not begin with a 0 or 1. </p><p>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. </p><p>All other area codes do not have parentheses around them as the area code is required for all calls. </p><p>Number formats are expressed as: </p><p>2+8 to represent (02x) xxxx xxxx [in 5 areas] or 05x xxxx xxxx or 070 xxxx xxxx. </p><p>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. </p><p>3+6 to represent 0500 xxxxxx or 0800 xxxxxx. </p><p>4+6 to represent (01xxx) xxxxxx [in 580 areas] or 07xxx xxxxxx. </p><p>4+5 to represent (01xxx) xxxxx [in 41 areas]. </p><p>5+5 to represent (01xx xx) xxxxx [in 12 areas]. </p><p>5+4 to represent (01xx xx) xxxx [in 1 area]. </p><p>Valid formats include:</p><p> (011x) - 3+7.</p><p> (01x1) - 3+7.</p><p> (01xxx) - 4+6 or 4+5.</p><p> (01xx xx) - 5+5 or 5+4.</p><p> (02x) - 2+8.</p><p> 03xx - 3+7.</p><p> 05x - 2+8.</p><p> 0500 - 3+6.</p><p> 07xxx - 4+6.</p><p> 070 - 2+8.</p><p> 08xx - 3+7.</p><p> 0800 - 3+7 or 3+6.</p><p> 09xx - 3+7.</p><p> There are a small number of exceptions such as 0800 1111 and 0845 4647.</p><p> The UK system is quite complex!</p>


Title: Reposted with corrections
Name: Reposted with corrections
Date: 12/1/2009 10:42:02 AM
Comment:
Reposted with corrections


Title: UK Telephone Number Formats in 2009.
Name: Steve
Date: 11/29/2009 6:07:08 AM
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. 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. 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: Correction
Name: Steve
Date: 11/29/2009 6:01:14 AM
Comment:
Please keep the post entitled ""UK Telephone Number Formats in 2009"" and delete the previous two copies with different title (and this note). The previous posts had a typo.


Title: UK Telephone Number Formats in 2009.
Name: Steve
Date: 11/29/2009 5:56:34 AM
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. 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 12 areas]. 5+5 to represent (01xx xx) xxxxx [in 41 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. 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.


Title: Doesn't quite work...
Name: Steve
Date: 11/29/2009 5:49:03 AM
Comment:
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. 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 12 areas]. 5+5 to represent (01xx xx) xxxxx [in 41 areas]. 5+4 to represent (01xx xx) xxxx [in 1 area]. Valid formats include: (011x) - 3+7 (01x1) - 3+7 (01xxx) - 4+6, 4+5 (01xx xx) - 5+5, 5+4 (02x) - 2+8 03xx - 3+7 05x - 2+8 0500 - 3+6 07xxx - 4+6 070 - 2+8 08xx - 3+7 0800 - 3+7, 3+6 09xx - 3+7


Title: Doesn't quite work...
Name: Steve
Date: 11/29/2009 5:48:45 AM
Comment:
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. 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 12 areas]. 5+5 to represent (01xx xx) xxxxx [in 41 areas]. 5+4 to represent (01xx xx) xxxx [in 1 area]. Valid formats include: (011x) - 3+7 (01x1) - 3+7 (01xxx) - 4+6, 4+5 (01xx xx) - 5+5, 5+4 (02x) - 2+8 03xx - 3+7 05x - 2+8 0500 - 3+6 07xxx - 4+6 070 - 2+8 08xx - 3+7 0800 - 3+7, 3+6 09xx - 3+7


Title: re: Doesn't quite work...
Name: Joe Gass
Date: 7/9/2004 8:26:59 AM
Comment:
Hi Dave, thanks for your comment Would you say that (\s*\(?0\d{4}\)?\s*\d{6}\s*)|(\s*\(?0\d{2}\)?\s*\d{4}\s*\d{4}\s*) would be a more accurate regex then?


Title: Doesn't quite work...
Name: David Keaveny
Date: 6/24/2004 8:12:56 AM
Comment:
I'm afraid you've got the London telephone codes wrong. Technically speaking, the area code for the whole of London is (020), not (0207) and (0208). The 7 or 8 digit is prefixed to the old 7 digit number. This means that both inner and outer London count as local to each other when dialling e.g. 7123 4567.


Title: another david waldock
Name: david waldock
Date: 2/16/2004 5:00:00 AM
Comment:
this is cool, never been bothered to find out how many david waldock's there is in the world. you seem to be one of them!#


Title: A good starting point
Name: Another David
Date: 7/16/2003 5:10:30 AM
Comment:
usefull regex


Title: My mistake
Name: David Waldock
Date: 7/9/2003 4:58:19 PM
Comment:
uhm. didn't realise that didn't do linefeeds. <br> following patterns are matched:<br> 00000000000 <br> 00000 000000 <br> 0000 000 0000 <br> 0000 0000000 <br> Apologies!


Title: Just a follow up...
Name: David Waldock
Date: 7/9/2003 4:55:06 PM
Comment:
^0\d{4}\s?\d{6}\s?|\s?0\d{3}\s?\d{3}\s?\d{4}$ Doesn't allow leading/trailing spaces (as I don't want them!) and also allows the following patterns: 00000 000000 0000 0000000 0000 000 0000 David


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