Regular Expressions for Validating and Formatting UK Telephone Numbers
From aa-asterisk.org.uk wiki
Territory ID: GB or UK
Country Code: +44
National Trunk Prefix: 0
International Dialling Prefix: 00
This is a short guide to validating and formatting UK telephone numbers.
The regular expressions shown here are very similar to those found in the data files used by the open source libphonenumber project. Here the data for GB, IM, GG, GJ is combined whereas libphonenumber treats them each as separate countries.
Allow the user to enter the telephone number in any format that seems sensible. Do a few basic checks on the prefix and length and then remove the +44 country code or 0 trunk code and any extension details from the number and store for later use.
Next, remove all punctuation and spaces from the remainder so that you're left with the 7, 9 or 10 digit National Significant Number.
Use the regular expressions below to determine whether the remaining number is in a valid range, is the correct length for that range, what type of number it is and then how to correctly format it.
There are also rules to determine which local subscriber number ranges and lengths are valid for each area code.
Selecting valid UK telephone number ranges
Before you start, there are four concepts that need to be separated. These are "input format", "valid number range and valid number length for this range", "storage format" and "display format".
Many systems try to constrain the user to typing numbers in a particular format, and this is usually a very bad idea. The London number 020 3000 5555 can be written as (020) 3000 5555 or as +44 20 3000 5555, but you'll equally see people writing 0203 000 5555, (0203) 000 5555, 02030 005 555, +44 (0) 20 3000 5555, +44(0)203 000 5555, 00 (44) 2030 005 555, (+44 203) 000 5555, (+44) 203 000 5555, 011 44 203 000 5555, and many others, and the same again each with hyphens in various positions.
The user should be allowed to do that. Most users do not properly understand how telephone numbers work nor the significance of the spaces and/or hyphens between country code, area code and local number. The number must be checked for validity and length and then reformatted for display by later more detailed logic elements.
Match UK telephone number in any format
Pattern: ^(?:(?:\(?(?:0(?:0|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-]?(?:x|ext\.?|\#)\d{3,4})?$
The above pattern matches 00 or 011 with optional parentheses, followed by optional space or hyphen, followed by optional opening parentheses; or, matches optional opening parentheses, followed by + without a following space or hyphen. This is then followed by 44 with optional closing parentheses followed by optional space or hyphen, followed by optional 0 in optional parentheses, followed by optional space or hyphen (international format). Alternatively, the pattern matches optional opening parentheses followed by the 0 trunk code (national format).
This is followed by the area code and phone number in 2+8, 3+7, 3+6, 4+6, 4+5, 5+5 or 5+4 format with or without spaces and/or hyphens. This includes provision for optional closing parentheses and/or optional space or hyphen after where the user thinks the area code ends and the local number begins. The pattern allows any format to be used with any UK number. The display format must be corrected by later logic if the wrong format for this number has been used by the user on input.
The pattern finally ends with optional space or hyphen followed by x, ext and optional period or #, followed by a three or four digit extension number.
Extract NSN, prefix and extension
After checking the input looks like a UK telephone number using the pattern above, the next step is to extract the NSN part so that it can be checked in greater detail for validity and then formatted in the right way for the applicable number range.
Pattern: ^(\(?(?:0(?:0|11)\)?[\s-]?\(?|\+)(44)\)?[\s-]?)?\(?0?(?:\)[\s-]?)?([1-9]\d{1,4}\)?[\d[\s-]]+)((?:x|ext\.?|\#)\d{3,4})?$
Use the above pattern to extract the '44' from $2 to know that international format was used, otherwise assume national format if $2 is null.
Extract the optional extension number details from $4 and store them for later use.
Extract the NSN (including spaces, hyphens and parentheses) from $3. Remove those spaces, hyphens and parentheses and use the RegEx patterns below to first determine the number type and then how to correctly format it.
Validate NSN by initial digits and length
If you need a very simple pattern to broadly accept various UK telephone numbers as potentially valid or not, try one of these listed immediately below. They are ordered in increasing detail.
Simple patterns grouped by initial digit
- Pattern: ^((1\d\d|800)\d{6,7}|[235789]\d{9}|500\d{6}|8(001111|45464\d))$
- Pattern: ^((1\d\d|800)\d{6,7}|(2[03489]|3[0347]|5[56]|7[04-9]|8[047]|9[018])\d{8}|500\d{6}|8(001111|45464\d))$
Simple patterns grouped by number length
- Pattern: ^([1235789]\d{9}|(1[2-9]\d|[58]00)\d{6}|8(001111|45464\d))$
- Pattern: ^((1[1-9]|2[03489]|3[0347]|5[56]|7[04-9]|8[047]|9[018])\d{8}|(1[2-9]\d|[58]00)\d{6}|8(001111|45464\d))$
The above patterns are very basic. Use the detailed patterns in the next sections for much better control. Those patterns are grouped by number range usage for validation and by initial digits for formatting.
Storage and display
The number should be stored (in a database or wherever) in E.164 format, with + sign, country code and NSN (i.e. area code/NDC if applicable, and local number); e.g. +44203000555 or +44175062555.
For display, there's a quite complex set of rules for the UK because different number ranges have a different total number of digits (usually 10 or 9, occasionally 7) and there are a variety of different area code lengths in use (from 2 to 5 digits). These rules are quite easy to understand and are listed on the number format page and detailed in the RegEx patterns in the following sections of this article. Use the E.123 format for display. You can choose to display the number in national format, e.g. 020 3000 5555 or (020) 3000 5555 or in full international format, e.g. +44 20 3000 5555. Do not use (0) in the international format.
Validating UK telephone numbers
The following RegEx patterns select valid UK telephone number ranges:
Ranges 2d, 11d, 1d1, 1ddd (and 1dddd) with 10 digits, 1ddd, 1dddd with 9 digits; including NDO
- Pre-match Pattern: ^\d{9,10}$
- Pattern: ^(2(?:0[01378]|3[0189]|4[017]|8[0-46-9]|9[012])\d{7}|1(?:(?:1(?:3[0-48]|[46][0-4]|5[012789]|7[0-49]|8[01349])|21[0-7]|31[0-8]|[459]1\d|61[0-46-9]))\d{6}|1(?:2(?:0[024-9]|2[3-9]|3[3-79]|4[1-689]|[58][02-9]|6[0-4789]|7[013-9]|9\d)|3(?:0\d|[25][02-9]|3[02-579]|[468][0-46-9]|7[1235679]|9[24578])|4(?:0[03-9]|2[02-5789]|[37]\d|4[02-69]|5[0-8]|[69][0-79]|8[0-5789])|5(?:0[1235-9]|2[024-9]|3[0145689]|4[02-9]|5[03-9]|6\d|7[0-35-9]|8[0-468]|9[0-5789])|6(?:0[034689]|2[0-689]|[38][013-9]|4[1-467]|5[0-69]|6[13-9]|7[0-8]|9[0124578])|7(?:0[0246-9]|2\d|3[023678]|4[03-9]|5[0-46-9]|6[013-9]|7[0-35-9]|8[024-9]|9[02-9])|8(?:0[35-9]|2[1-5789]|3[02-578]|4[0-578]|5[124-9]|6[2-69]|7\d|8[02-9]|9[02569])|9(?:0[02-589]|2[02-689]|3[1-5789]|4[2-9]|5[0-579]|6[234789]|7[0124578]|8\d|9[2-57]))\d{6}|1(?:2(?:0(?:46[1-4]|87[2-9])|545[1-79]|76(?:2\d|3[1-8]|6[1-6])|9(?:7(?:2[0-4]|3[2-5])|8(?:2[2-8]|7[0-4789]|8[345])))|3(?:638[2-5]|647[23]|8(?:47[04-9]|64[015789]))|4(?:044[1-7]|20(?:2[23]|8\d)|6(?:0(?:30|5[2-57]|6[1-8]|7[2-8])|140)|8(?:052|87[123]))|5(?:24(?:3[2-79]|6\d)|276\d|6(?:26[06-9]|686))|6(?:06(?:4\d|7[4-79])|295[567]|35[34]\d|47(?:24|61)|59(?:5[08]|6[67]|74)|955[0-4])|7(?:26(?:6[13-9]|7[0-7])|442\d|50(?:2[0-3]|[3-68]2|76))|8(?:27[56]\d|37(?:5[2-5]|8[239])|84(?:3[2-58]))|9(?:0(?:0(?:6[1-8]|85)|52\d)|3583|4(?:66[1-8]|9(?:2[01]|81))|63(?:23|3[1-4])|9561))\d{3}|176888[234678]\d{2}|16977[23]\d{3})$
- Number Type: Fixed Line
- Example Number: 1212345678
Note: Pattern matches geographic NSN=10 numbers as follows:
- area code and subscriber number first digit for 2+8,
- area code and subscriber number first digit for 3+7,
- area code only for 4+6 (including mixed areas with embedded 5+5).
Note: Pattern matches geographic NSN=9 numbers as follows:
- area code and subscriber number first two digits for most 4+5 numbers,
- area code and subscriber number first three digits for 4+5 special case (01768) 88Ddd,
- area code and subscriber number first digit for 5+4 special case (016977) Dddd.
Ranges 2d, 11d, 1d1, 1ddd (and 1dddd) with 10 digits, 1ddd, 1dddd with 9 digits; excluding NDO
- Pre-match Pattern: ^\d{9,10}$
- Pattern: ^(2\d[2-9]\d{7}|1(?:1\d|\d1)[2-9]\d{6}|1(?:[248][02-9]\d[2-9]\d{4,5}|(?:3(?:[02-79]\d|8[0-69])|5(?:[04-9]\d|2[0-35-9]|3[0-8])|6(?:[02-8]\d|9[0-689])|7(?:[02-5789]\d|6[0-79])|9(?:[0235-9]\d|4[0-5789]))[2-9]\d{4,5}|(?:387(?:3[2-9]|[24-9]\d)|5(?:24(?:2[2-9]|[3-9]\d)|39(?:[4-6][2-9]|[237-9]\d))|697(?:[347][2-9]|[25689]\d)|768(?:[347][2-9]|[25679]\d)|946(?:7[2-9]|[2-689]\d))\d{3,4}))$
- Number Type: Fixed Line, Area Code Optional
- Example Number: 1332456789
Note: These are a subset of the fixed-line rules, with digits 2 to 9 as the leading digit of the subscriber number. There are patterns for 2+8, 3+7 and a combined pattern for all 4+6/4+5 and 5+5/5+4 numbers. Note that numbers matching this pattern are not necessarily valid numbers. Enclose the area code part in parentheses when formatting these numbers.
Ranges 7ddd (including 7624) (not 70, 76) (excluding protected ranges) with 10 digits
- Pre-match Pattern: ^\d{10}$
- Pattern: ^7(?:[1-4]\d\d|5(?:0[0-8]|[13-9]\d|2[0-35-9])|624|7(?:0[1-9]|[1-7]\d|8[02-9]|9[0-689])|8(?:[014-9]\d|[23][0-8])|9(?:[04-9]\d|1[02-9]|2[0-35-9]|3[0-689]))\d{6}$
- Number Type: Mobile
- Example Number: 7400123456
Ranges 76 (excluding 7624) with 10 digits
- Pre-match Pattern: ^\d{10}$
- Pattern: ^76(?:0[012]|2[356]|4[0134]|5[49]|6[0-369]|77|81|9[39])\d{6}$
- Number Type: Pager
- Example Number: 7640123456
Ranges 800 1111 with 7 digits, 800 with 9 or 10 digits, 808 with 10 digits, 500 with 9 digits
- Pre-match Pattern: ^\d{7}(?:\d{2,3})?$
- Pattern: ^80(?:0(?:1111|\d{6,7})|8\d{7})|500\d{6}$
- Number Type: Toll Free (Freefone)
- Example Number: 8001234567
Ranges 871, 872, 873, 90d, 91d, 980, 981, 982, 983 with 10 digits
- Pre-match Pattern: ^\d{10}$
- Pattern: ^(?:87[123]|9(?:[01]\d|8[0-3]))\d{7}$
- Number Type: Premium Rate
- Example Number: 9012345678
Ranges 845 46 4d with 7 digits, 842, 843, 844, 845, 870 with 10 digits
- Pre-match Pattern: ^\d{7}(?:\d{3})?$
- Pattern: ^8(?:4(?:5464\d|[2-5]\d{7})|70\d{7})$
- Number Type: Shared Cost
- Example Number: 8431234567
Ranges 70 with 10 digits
- Pre-match Pattern: ^\d{10}$
- Pattern: ^70\d{8}$
- Number Type: Personal Number
- Example Number: 7012345678
Ranges 56 with 10 digits
- Pre-match Pattern: ^\d{10}$
- Pattern: ^56\d{8}$
- Number Type: VoIP
- Example Number: 5612345678
Ranges 30d, 33d, 34d, 37d, 55 with 10 digits
- Pre-match Pattern: ^\d{10}$
- Pattern: ^(?:3[0347]|55)\d{8}$
- Number Type: UAN
- Example Number: 5512345678
Notes
- Mark all other number ranges as non-valid.
Formatting UK telephone numbers
Valid UK telephone number ranges can be formatted as follows:
Ranges 2d, 55, 56, 70, 76 (excluding 7624) with 10 digits
- Leading Digits: ^(?:2|5[56]|7(?:0|6(?:[013-9]|2[0-35-9])))
- Pattern: ^(\d{2})(\d{4})(\d{4})$
- Format: $1 $2 $3
Ranges 11d, 1d1, 3dd, 9dd with 10 digits
- Leading Digits: ^(?:1(?:1|\d1)|3|9[018])
- Pattern: ^(\d{3})(\d{3})(\d{4})$
- Format: $1 $2 $3
Ranges 1dddd with 9 or 10 digits
- Leading Digits: ^(?:1(?:3873|5(?:242|39[456])|697[347]|768[347]|9467))
- Pattern: ^(\d{5})(\d{4,5})$
- Format: $1 $2
Note: These area codes are very rare in GB, and are only available in the following places: 13873 (Langholm), 15242 (Hornby-with-Farleton), 15394 (Hawkshead), 15395 (Grange-over-Sands), 15396 (Sedbergh), 16973 (Wigton), 16974 (Raughton Head), 16977 (Brampton), 17683 (Appleby-in-Westmorland), 17684 (Pooley Bridge), 17687 (Keswick), 19467 (Gosforth).
Ranges 1ddd with 9 or 10 digits
- Leading Digits: ^1
- Pattern: ^(1\d{3})(\d{5,6})$
- Format: $1 $2
Ranges 7ddd (including 7624) (not 70, 76) with 10 digits
- Leading Digits: ^7(?:[1-5789]|624)
- Pattern: ^(7\d{3})(\d{6})$
- Format: $1 $2
Ranges 800 1111 with 7 digits : UK ChildLine
- Leading Digits: ^8001111
- Pattern: ^(800)(\d{4})$
- Format: $1 $2
Ranges 845 46 47 with 7 digits : UK NHS Direct
- Leading Digits: ^845464
- Pattern: ^(845)(46)(4\d)$
- Format: $1 $2 $3
Note: This format actually applies to 0845 46 4x, not just to 0845 46 47, but the other nine numbers are unallocated.
Ranges 84d, 87d with 10 digits
- Leading Digits: ^8(?:4[2-5]|7[0-3])
- Pattern: ^(8\d{2})(\d{3})(\d{4})$
- Format: $1 $2 $3
Ranges 80d (including 800) with 10 digits
- Leading Digits: ^80[08]
- Pattern: ^(80\d)(\d{3})(\d{4})$
- Format: $1 $2 $3
Ranges 500, 800 with 9 digits
- Leading Digits: ^[58]00
- Pattern: ^([58]00)(\d{6})$
- Format: $1 $2
Notes
- Several of the above formatting rules can be combined for more efficient operation.
- Prefix the above formatted numbers with the +44 country code and a space or with the 0 trunk code.
- For national format numbers in 01 and 02 area codes and where the subscriber number does not begin with 0 or 1, the area code can be enclosed in parentheses. This signifies the area code is optional when calling from another number within the same area code.
- Present all other numbers as unformatted.
Local dialling rules for UK telephone numbers
Details of valid local numbers for various UK area codes:
Local dialling in mixed 5+5/5+4 areas
Numbers begin 2 to 9 and may have different lengths (4 or 5 digits) depending on the value of the initial digit:
- Local dialling from 016977 mixed (5+5/5+4) area: ^(([2-8]\d\d|9[0-8]\d|99[0-8])\d{2}|[23]\d{3})$
Local numbers beginning with 2 or 3 have only 4 digits.
Local dialling in mixed 5+5 areas
Numbers begin 2 to 9 and will always have 5 digits:
- Local dialling from all other mixed 5+5 areas: ^(([2-8]\d\d|9[0-8]\d|99[0-8])\d{2})$
These mixed 5+5 area codes are 013873, 015242, 015394, 015395, 015396, 016973, 016974, 017683, 017684, 017687 and 019467; i.e. ^(?:1(?:3873|5(?:242|39[456])|697[34]|768[347]|9467))
Local dialling in mixed 4+6/4+5 areas
Numbers will not begin with all digits 2 to 9 and may have different lengths (5 or 6 digits) depending on the value of the initial two digits:
- Local dialling from 01524 mixed (4+6/4+5) area: ^(([3-8]\d\d|9[0-8]\d|99[0-8])\d{3}|(3[2-79]|6\d)\d{3})$
Local numbers cannot begin 2.
Pattern also caters for 5 digit local numbers beginning 32-37, 39 and 60-69.
- Local dialling from 01768 mixed (4+6/4+5) area: ^(([2568]\d\d|9[0-8]\d|99[0-8])\d{3}|88[234678]\d{2})$
Local numbers cannot begin 3, 4 or 7.
Pattern also caters for 5 digit local numbers beginning 882, 883, 884, 886, 887 and 888.
- Local dialling from 01946 mixed (4+6/4+5) area: ^(([2-68]\d\d|9[0-8]\d|99[0-8])\d{3}|6[1-8]\d{3})$
Local numbers cannot begin 7.
Pattern also caters for 5 digit local numbers beginning 61-68.
Local dialling in mixed 4+6 areas
Numbers will not begin with all digits 2 to 9 and will always have 6 digits:
- Local dialling from 01387 mixed (4+6) area: ^(([24-8]\d\d|9[0-8]\d|99[0-8])\d{3})$
Local numbers cannot begin 3.
- Local dialling from 01539 mixed (4+6) area: ^(([2378]\d\d|9[0-8]\d|99[0-8])\d{3})$
Local numbers cannot begin 4, 5 or 6.
- Local dialling from 01697 mixed (4+6) area: ^(([2568]\d\d|9[0-8]\d|99[0-8])\d{3})$
Local numbers cannot begin 3, 4 or 7.
Local dialling in 4+6/4+5 areas
Numbers begin 2 to 9 and may have different lengths (5 or 6 digits) depending on the value of the initial two digits:
Simple version
If you do NOT want to specify local dialling rules for each individual 4+6/4+5 area, use the simple version:
- Local dialling from all other 4+6/4+5 areas: ^(([2-8]\d\d|9[0-8]\d|99[0-8])\d{2,3})$
This pattern is for use in the following area codes: 01204, 01208, 01254, 01276, 01297, 01298, 01363, 01364, 01384, 01386, 01404, 01420, 01460, 01461, 01480, 01488, 01527, 01562, 01566, 01606, 01629, 01635, 01647, 01659, 01695, 01726, 01744, 01750, 01827, 01837, 01884, 01900, 01905, 01935, 01949, 01963 and 01995; i.e. ^(?:1(?:2(?:0[48]|54|76|9[78])|3(?:6[34]|8[46])|4(?:04|20|6[01]|8[08])|5(?:27|6[26])|6(?:06|29|35|47|59|95)|7(?:26|44|50)|8(?:27|37|84)|9(?:0[05]|35|49|63|95)))
The pattern allows for 5 and 6 digit local numbers without specifying all of the individual ranges within each area code.
See the section immediately below if you DO wish to state the local number ranges using 5 digits for each area code individually.
Detailed version
If you DO want to specify local dialling rules for each individual 4+6/4+5 area, they are detailed as follows:
- Local dialling from 01204 (4+6/4+5) area: ^(([2-8]\d\d|9[0-8]\d|99[0-8])\d{3}|6[1-4]\d{3})$
Pattern also caters for 5 digit local numbers beginning 61-64.
- Local dialling from 01208 (4+6/4+5) area: ^(([2-8]\d\d|9[0-8]\d|99[0-8])\d{3}|7[2-9]\d{3})$
Pattern also caters for 5 digit local numbers beginning 72-79.
- Local dialling from 01254 (4+6/4+5) area: ^(([2-8]\d\d|9[0-8]\d|99[0-8])\d{3}|5[1-79]\d{3})$
Pattern also caters for 5 digit local numbers beginning 51-57 and 59.
- Local dialling from 01276 (4+6/4+5) area: ^(([2-8]\d\d|9[0-8]\d|99[0-8])\d{3}|(2\d|3[1-8]|6[1-6])\d{3})$
Pattern also caters for 5 digit local numbers beginning 20-29, 31-38 and 61-66.
- Local dialling from 01297 (4+6/4+5) area: ^(([2-8]\d\d|9[0-8]\d|99[0-8])\d{3}|(2[0-4]|3[2-5])\d{3})$
Pattern also caters for 5 digit local numbers beginning 20-24 and 32-35.
- Local dialling from 01298 (4+6/4+5) area: ^(([2-8]\d\d|9[0-8]\d|99[0-8])\d{3}|(2[2-8]|7[0-47-9]|8[3-5])\d{3})$
Pattern also caters for 5 digit local numbers beginning 22-28, 70-74, 77-79 and 83-85.
- Local dialling from 01363 (4+6/4+5) area: ^(([2-8]\d\d|9[0-8]\d|99[0-8])\d{3}|8[2-5]\d{3})$
Pattern also caters for 5 digit local numbers beginning 82-85.
- Local dialling from 01364 (4+6/4+5) area: ^(([2-8]\d\d|9[0-8]\d|99[0-8])\d{3}|7[23]\d{3})$
Pattern also caters for 5 digit local numbers beginning 72 and 73.
- Local dialling from 01384 (4+6/4+5) area: ^(([2-8]\d\d|9[0-8]\d|99[0-8])\d{3}|7[04-9]\d{3})$
Pattern also caters for 5 digit local numbers beginning 70 and 74-79.
- Local dialling from 01386 (4+6/4+5) area: ^(([2-8]\d\d|9[0-8]\d|99[0-8])\d{3}|4[0157-9]\d{3})$
Pattern also caters for 5 digit local numbers beginning 40, 41, 45 and 47-49.
- Local dialling from 01404 (4+6/4+5) area: ^(([2-8]\d\d|9[0-8]\d|99[0-8])\d{3}|4[1-7]\d{3})$
Pattern also caters for 5 digit local numbers beginning 41-47.
- Local dialling from 01420 (4+6/4+5) area: ^(([2-8]\d\d|9[0-8]\d|99[0-8])\d{3}|(2[23]|8\d)\d{3})$
Pattern also caters for 5 digit local numbers beginning 22, 23 and 80-89.
- Local dialling from 01460 (4+6/4+5) area: ^(([2-8]\d\d|9[0-8]\d|99[0-8])\d{3}|(30|5[2-57]|6[1-8]|7[2-8])\d{3})$
Pattern also caters for 5 digit local numbers beginning 30, 52-55, 57, 61-68 and 72-78.
- Local dialling from 01461 (4+6/4+5) area: ^(([2-8]\d\d|9[0-8]\d|99[0-8])\d{3}|40\d{3})$
Pattern also caters for 5 digit local numbers beginning 40.
- Local dialling from 01480 (4+6/4+5) area: ^(([2-8]\d\d|9[0-8]\d|99[0-8])\d{3}|52\d{3})$
Pattern also caters for 5 digit local numbers beginning 52.
- Local dialling from 01488 (4+6/4+5) area: ^(([2-8]\d\d|9[0-8]\d|99[0-8])\d{3}|7[1-3]\d{3})$
Pattern also caters for 5 digit local numbers beginning 71-73.
- Local dialling from 01527 (4+6/4+5) area: ^(([2-8]\d\d|9[0-8]\d|99[0-8])\d{3}|6\d{4})$
Pattern also caters for 5 digit local numbers beginning 60-69.
- Local dialling from 01562 (4+6/4+5) area: ^(([2-8]\d\d|9[0-8]\d|99[0-8])\d{3}|6[06-9]\d{3})$
Pattern also caters for 5 digit local numbers beginning 60 and 66-69.
- Local dialling from 01566 (4+6/4+5) area: ^(([2-8]\d\d|9[0-8]\d|99[0-8])\d{3}|86\d{3})$
Pattern also caters for 5 digit local numbers beginning 86.
- Local dialling from 01606 (4+6/4+5) area: ^(([2-8]\d\d|9[0-8]\d|99[0-8])\d{3}|(4\d|7[4-79])\d{3})$
Pattern also caters for 5 digit local numbers beginning 40-49, 74-77 and 79.
- Local dialling from 01629 (4+6/4+5) area: ^(([2-8]\d\d|9[0-8]\d|99[0-8])\d{3}|5[5-7]\d{3})$
Pattern also caters for 5 digit local numbers beginning 55-57.
- Local dialling from 01635 (4+6/4+5) area: ^(([2-8]\d\d|9[0-8]\d|99[0-8])\d{3}|[34]\d{4})$
Pattern also caters for 5 digit local numbers beginning 30-39 and 40-49.
- Local dialling from 01647 (4+6/4+5) area: ^(([2-8]\d\d|9[0-8]\d|99[0-8])\d{3}|(24|61)\d{3})$
Pattern also caters for 5 digit local numbers beginning 24 and 61.
- Local dialling from 01659 (4+6/4+5) area: ^(([2-8]\d\d|9[0-8]\d|99[0-8])\d{3}|(5[08]|6[67]|74)\d{3})$
Pattern also caters for 5 digit local numbers beginning 50, 58, 66, 67 and 74.
- Local dialling from 01695 (4+6/4+5) area: ^(([2-8]\d\d|9[0-8]\d|99[0-8])\d{3}|5[0-4]\d{3})$
Pattern also caters for 5 digit local numbers beginning 50-54.
- Local dialling from 01726 (4+6/4+5) area: ^(([2-8]\d\d|9[0-8]\d|99[0-8])\d{3}|(6[13-9]|7[0-7])\d{3})$
Pattern also caters for 5 digit local numbers beginning 61, 63-69 and 70-77.
- Local dialling from 01744 (4+6/4+5) area: ^(([2-8]\d\d|9[0-8]\d|99[0-8])\d{3}|2\d{4})$
Pattern also caters for 5 digit local numbers beginning 20-29.
- Local dialling from 01750 (4+6/4+5) area: ^(([2-8]\d\d|9[0-8]\d|99[0-8])\d{3}|(2[0-3]|[34568]2|76)\d{3})$
Pattern also caters for 5 digit local numbers beginning 20-23, 32, 42, 52, 62, 76 and 82.
- Local dialling from 01827 (4+6/4+5) area: ^(([2-8]\d\d|9[0-8]\d|99[0-8])\d{3}|[56]\d{4})$
Pattern also caters for 5 digit local numbers beginning 50-59 and 60-69.
- Local dialling from 01837 (4+6/4+5) area: ^(([2-8]\d\d|9[0-8]\d|99[0-8])\d{3}|(5[2-5]|8[239])\d{3})$
Pattern also caters for 5 digit local numbers beginning 52-55, 82, 83 and 89.
- Local dialling from 01884 (4+6/4+5) area: ^(([2-8]\d\d|9[0-8]\d|99[0-8])\d{3}|3[2-58]\d{3})$
Pattern also caters for 5 digit local numbers beginning 32-35 and 38.
- Local dialling from 01900 (4+6/4+5) area: ^(([2-8]\d\d|9[0-8]\d|99[0-8])\d{3}|(6[1-8]|85)\d{3})$
Pattern also caters for 5 digit local numbers beginning 61-68 and 85.
- Local dialling from 01905 (4+6/4+5) area: ^(([2-8]\d\d|9[0-8]\d|99[0-8])\d{3}|2\d{4})$
Pattern also caters for 5 digit local numbers beginning 20-29.
- Local dialling from 01935 (4+6/4+5) area: ^(([2-8]\d\d|9[0-8]\d|99[0-8])\d{3}|83\d{3})$
Pattern also caters for 5 digit local numbers beginning 83.
- Local dialling from 01949 (4+6/4+5) area: ^(([2-8]\d\d|9[0-8]\d|99[0-8])\d{3}|(2[01]|81)\d{3})$
Pattern also caters for 5 digit local numbers beginning 20, 21 and 81.
- Local dialling from 01963 (4+6/4+5) area: ^(([2-8]\d\d|9[0-8]\d|99[0-8])\d{3}|(23|3[1-4])\d{3})$
Pattern also caters for 5 digit local numbers beginning 23 and 31-34.
- Local dialling from 01995 (4+6/4+5) area: ^(([2-8]\d\d|9[0-8]\d|99[0-8])\d{3}|61\d{3})$
Pattern also caters for 5 digit local numbers beginning 61.
Local dialling in 4+6 areas
Numbers begin 2 to 9 and will always have 6 digits:
- Local dialling from all other 4+6 areas: ^(([2-8]\d\d|9[0-8]\d|99[0-8])\d{3})$
This pattern is for use in 4+6 areas beginning 01200 to 01998 (but not 01x1 areas) that do NOT have any 4+5 numbers and/or mixed 5+5 area codes within; i.e. ^(?:1[2-9][02-9]\d) where not already matched by an earlier rule. This rule covers these area codes: ^(?:1(?:2(?:0[025-79]|2[3-9]|3[3-79]|4[1-689]|[5[0235-9]|6[0-4789]|7[013-57-9]|8[02-9]|9[0-69])|3(?:0\d|[25][02-9]|3[02-579]|4[0-46-9]|6[0-26-9]|7[1235679]|8[0-389]|9[24578])|4(?:0[035-9]|2[2-5789]|[37]\d|4[02-69]|5[0-8]|6[2-79]|8[1-579]|9[0-79])|5(?:0[1235-9]|2[025689]|3[014568]|4[02-9]|5[03-9]|6[01345789]|7[0-35-9]|8[0-468]|9[0-5789])|6(?:0[03489]|2[0-68]|3[01346-9]|4[1-46]|5[0-6]|6[13-9]|7[0-8]|8[013-9]|9[01248])|7(?:0[0246-9]|2[0-57-9]|3[023678]|4[035-9]|5[1-46-9]|6[013-79]|7[0-35-9]|8[024-9]|9[02-9])|8(?:0[35-9]|2[1-589]|3[02-58]|4[0-578]|5[124-9]|6[2-69]|7\d|8[0235-9]|9[02569])|9(?:0[2-489]|2[02-689]|3[1-4789]|4[2-57]|5[0-579]|6[24789]|7[0124578]|8\d|9[2-47])))
Local dialling in 3+7 areas
Numbers begin 2 to 9 (but not all values may be in use yet) and will always have 7 digits:
Simple version
- Local dialling from all 011x (3+7) areas: ^(([2-8]\d\d|9[0-8]\d|99[0-8])\d{4})$
This pattern is for use in the following area codes: 0113, 0114, 0115, 0116, 0117 and 0118; i.e. ^(?:11[3-8])
The pattern ignores the fact that various local number ranges are not yet in use.
- Local dialling from all 01x1 (3+7) areas: ^(([2-8]\d\d|9[0-8]\d|99[0-8])\d{4})$
This pattern is for use in the following area codes: 0121, 0131, 0141, 0151, 0161 and 0191; i.e. ^(?:1[2-69]1)
The pattern ignores the fact that (0121) 8, (0121) 9, (0131) 9 and (0161) 5 are not yet in use.
Detailed version
- Local dialling from 0113 (3+7) area: ^([2348]\d{6})$
Local numbers begin 2, 3, 4 and 8.
- Local dialling from 0114 (3+7) area: ^([234]\d{6})$
Local numbers begin 2, 3 and 4.
- Local dialling from 0115 (3+7) area: ^(([278]\d\d|9[0-8]\d|99[0-8])\d{4})$
Local numbers begin 2, 7, 8 and 9.
- Local dialling from 0116 (3+7) area: ^([234]\d{6})$
Local numbers begin 2, 3 and 4.
- Local dialling from 0117 (3+7) area: ^(([234]\d\d|9[0-8]\d|99[0-8])\d{4})$
Local numbers begin 2, 3, 4 and 9.
- Local dialling from 0118 (3+7) area: ^(([34]\d\d|9[0-8]\d|99[0-8])\d{4})$
Local numbers begin 3, 4 and 9.
- Local dialling from 0121 (3+7) area: ^(([2-7]\d{6})$
Local numbers begin 2 to 7.
- Local dialling from 0131 (3+7) area: ^(([2-8]\d{6})$
Local numbers begin 2 to 8.
- Local dialling from 0141 (3+7) area: ^(([2-8]\d\d|9[0-8]\d|99[0-8])\d{4})$
Local numbers begin 2 to 9.
- Local dialling from 0151 (3+7) area: ^(([2-8]\d\d|9[0-8]\d|99[0-8])\d{4})$
Local numbers begin 2 to 9.
- Local dialling from 0161 (3+7) area: ^(([2-46-8]\d\d|9[0-8]\d|99[0-8])\d{4})$
Local numbers begin 2 to 4 and 6 to 9.
- Local dialling from 0191 (3+7) area: ^(([2-8]\d\d|9[0-8]\d|99[0-8])\d{4})$
Local numbers begin 2 to 9.
Local dialling in 2+8 areas
Numbers will not begin with all digits 2 to 9 and will always have 8 digits:
Simple version
- Local dialling from all 02x (2+8) areas: ^(([2-8]\d\d|9[0-8]\d|99[0-8])\d{5})$
This pattern is for use in the following area codes: 020, 023, 024, 028, and 029; i.e. ^(?:2[03489])
The pattern ignores the fact that not all possible number ranges are in use within each area code.
Detailed version
- Local dialling from 020 (2+8) area: ^([378]\d{7})$
Local numbers begin 3x, 7x and 8x.
- Local dialling from 023 (2+8) area: ^((8[0-2]|9[2-4])\d{6})$
Local numbers begin 80, 81 (and soon 82), 92, 93 (and soon 94).
- Local dialling from 024 (2+8) area: ^(7[5-7]\d{6})$
Local numbers begin 75, 76, 77.
- Local dialling from 028 (2+8) area: ^((2[015789]|3[078]|4[0-4]|6[678]|7[0179]|8[0125679]|9[0-8])\d{6})$
Local numbers begin 2x, 3x, 4x, 6x, 7x, 8x and 9x as detailed above.
- Local dialling from 029 (2+8) area: ^(2[0-3]\d{6})$
Local numbers begin 20, 21, 22 (and soon 23).
See also
- National Telephone Numbering Plan
- Number format
- Charge group
- Area code
- Trunk code
- 01 numbers
- 02 numbers
- ELNS areas
- Mixed areas
- Sabc.txt
- E.123
- NDO
- NDC
- NSN
- (0)
- Errors in Cisco UK Numbering Plan Documents
- libphonenumber
