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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find UK Postcode District (Loose Match)
Expression
[A-Za-z]{1,2}[\d]{1,2}[A-Za-z]{0,1}
Description
The postcode district is the first block of a UK postcode. For example with DN55 1PT it would match DN55. Its a loose match as it only ensures that the format is correct, it doesn't validate the letters and numbers. It doesn't let in the non-geographic codes postcodes SAN TA1 and GIR 0AA. It will pull out the first block of any of the matching examples below. Examples of the names of the different parts of a UK postcode can be found here: http://en.wikipedia.org/wiki/Postcodes_in_the_United_Kingdom#Life-cycle_of_post_codes
Matches
AA9A 9AA | A9A 9AA | A9 9AA | A99 9AA | AA9 9AA | AA99 9AA | EC1A 1BB | W1A 1HQ | M1 1AA | B33 8TH | CR2 6XH | DN55 1PT
Non-Matches
SAN TA1 | GIR 0AA
Author Rating: Not yet rated. Matthew Harris
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

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