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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find UK Postcode District
Expression
([A-PR-UWYZa-pr-uwyz]([0-9]{1,2}|([A-HK-Ya-hk-y][0-9]|[A-HK-Ya-hk-y][0-9]([0-9]|[ABEHMNPRV-Yabehmnprv-y]))|[0-9][A-HJKS-UWa-hjks-uw]))
Description
Matches the first part of a UK Postcode (known as a postcode district). Case insensitive. Doesnt match: GIR # the postcode for the formerly Post Office-owned Girobank is GIR 0AA. SAN # the postcode for correctly addressed letters to Father Christmas is SAN TA1
Matches
LN5 | SW1 | ln5
Non-Matches
ln5 7nq | GIR | SAN
Author Rating: Not yet rated. Matthew Harris
Source http://chillisource.blogspot.com/2008/03/regex-for-uk-postcode.html
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: Request
Name: Hattensh
Date: 1/9/2012 3:54:26 AM
Comment:
Hi I am trying to validate the first part of the postcode e.g. LS12 this regex seems to only work for LS1, BD5 etc


Title: Request
Name: Hattensh
Date: 1/9/2012 3:54:20 AM
Comment:
Hi I am trying to validate the first part of the postcode e.g. LS12 this regex seems to only work for LS1, BD5 etc


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