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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Validate UK telephone number NSN by initial digits and length (simple version).
Expression
^((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))$
Description
Step 3: Validate the NSN produced from the pattern in step 2 and check it for length and validity. The pattern here is fairly basic. More detailed patterns for each number type are available elsewhere. Step 4 is to format the number correctly. This needs a variety of RegEx patterns each based on the initial digits and number length.
Matches
20 3000 5555, 121 555 7777, 1750 618888, 1750 62555, 19467 55555, 16977 3555, 303 555 7788, 500 777999, 55 4455 7788, 70 7788 5577, 800 555777, 800 444 7799, 845 333 5577, 871 444 5577, 909 555 7788 after removing spaces
Non-Matches
20 444 666, 20 555 7777, 1999 5577, 1999 555 7799, 22 5000 7777, 800 55555, 803 555777, 815 555 7777, 845 8888 9999
Author Rating: The rating for this expression. g1smd
Source http://www.aa-asterisk.org.uk/index.php/Regular_Expressions_for_Validating_and_Formatting_GB_Telephone_Numbers
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: Validate UK telephone numbers in a few simple steps.
Name: g1smd
Date: 10/27/2012 2:12:16 PM
Comment:
See posts 3606 and 3607 for previous steps and post 3609 for a more detailed version of this step.


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