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: The rating for this expression. 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: Scam victims
Name: Jimmy
Date: 10/20/2025 1:21:59 PM
Comment:
I was a scam victim, I lost a lot of money up to $170,000 I would like to express my gratitude to Innovations recovery Analyst for their exceptional assistance in recovering my funds from a forex broker. Their expertise and professionalism in navigating the complex process were truly commendable. Through their guidance and relentless efforts, I was able to successfully retrieve my funds of $170,000, providing me with much-needed relief. I highly recommend them on - INNOVATIONSANALYST@ GMAIL. COM or WhatsApp + 1 424 285 0682 to anyone facing similar challenges, as their dedication and commitment to helping clients are truly impressive. Thank you, for your invaluable support in resolving this matter.


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-2025, RegexAdvice.com | ASP.NET Tutorials