| Title |
Test
Find
Pattern Title
|
| Expression |
^(((\+44\s?\d{4}|\(?0\d{4}\)?)\s?\d{3}\s?\d{3})|((\+44\s?\d{3}|\(?0\d{3}\)?)\s?\d{3}\s?\d{4})|((\+44\s?\d{2}|\(?0\d{2}\)?)\s?\d{4}\s?\d{4}))(\s?\#(\d{4}|\d{3}))?$ |
| Description |
Modified version of UK phone number regular expression. Now allows +44 national code in addition to extension numbers of 3 or 4 digits. Previous expression was: ^((\(?0\d{4}\)?\s?\d{3}\s?\d{3})|(\(?0\d{3}\)?\s?\d{3}\s?\d{4})|(\(?0\d{2}\)?\s?\d{4}\s?\d{4}))(\s?#(\d{4}|\d{3}))?$ |
| Matches |
+447222555555 | +44 7222 555 555 | (0722) 5555555 #2222 |
| Non-Matches |
(+447222)555555 | +44(7222)555555 | (0722) 5555555 #22 |
| Author |
Rating:
Amos Hurd
|
| Source |
|
| Your Rating |
|
Title: UK Telephone Number Formats
Name: Steve
Date: 12/25/2009 2:33:11 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: Some UK numbers are only 10 digits
Name: Ray
Date: 1/16/2009 6:48:26 AM
Comment:
Fails on my home number which is of the form 01606 12 345.
I modified it to:
^(((\+44\s?\d{4}|\(?0\d{4}\)?)\s?\d{2,3}\s?\d{3})|((\+44\s?\d{3}|\(?0\d{3}\)?)\s?\d{2,3}\s?\d{4})|((\+44\s?\d{2}|\(?0\d{2}\)?)\s?\d{4}\s?\d{4}))(\s?\#(\d{4}|\d{3}))?$
which works for me but i haven't tested thoroughly.
Amusingly BT can't validate my number either!
Title: PHP w/ CakePHP
Name: Dave
Date: 8/11/2008 7:55:12 AM
Comment:
I tried implementing this into the CakePHP 1.2 phone validation method as the default is for US numbers only, doesn't seem to validate which is kind of strange.
Title: Comments
Name: Mukesh Pandey
Date: 9/2/2004 2:56:01 AM
Comment:
Very Nice for UK Numbers
Title: If you comment ...
Name: Amos Hurd
Date: 7/8/2004 11:07:51 AM
Comment:
If there are problems, please let me know under what circumstances the expression fails. Simple testing via the "Test" link seemed to work fine for .Net today.
Title: not for .Net
Name: Gus
Date: 7/8/2004 11:01:52 AM
Comment:
This expr. does not work in .net for some reason
Title: Updated
Name: Amos Hurd
Date: 6/24/2004 8:42:26 AM
Comment:
Updated to preceed the "#" symbol with "\" to avoid the rest of the line being taken as a comment.