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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Extract NSN, prefix and extension from UK telephone number.
Expression
^\(?(?:(?:0(?:0|11)\)?[\s-]?\(?|\+)(44)\)?[\s-]?\(?(?:0\)?[\s-]?\(?)?|0)([1-9]\d{1,4}\)?[\s\d-]+)(?:((?:x|ext\.?\s?|\#)\d+)?)$
Description
Step 2: After step 1 has verified the input is likely to be a UK telephone number, this pattern extracts the NSN part of the number so that it can be passed to another routine that will check it for length and validity. $1 is 44 (international format) or null (use 0 for trunk code - national format). $2 is the NSN. $3 is the extension number.
Matches
020 3000 5555, (020) 3000 5555, +44 20 3000 5555, 00 44 20 3000 5555, 011 44 20 3000 5555, 0203 000 5555, 02030 005 555, (+44) 20 3000 5555, (+44 20) 3000 5555, and many others, any with NSN of 10 or 9.
Non-Matches
01750 5555, 0203 5555 7777, +33 1 2345 6789
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:09:36 PM
Comment:
See post 3606 for previous step and posts 3608, 3609 for further steps.


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