Title |
Test
Find
UK Postcode Validation
|
Expression |
^(GIR ?0AA|(?:[A-PR-UWYZ](?:\d|\d{2}|[A-HK-Y]\d|[A-HK-Y]\d\d|\d[A-HJKSTUW]|[A-HK-Y]\d[ABEHMNPRV-Y])) ?\d[ABD-HJLNP-UW-Z]{2})$ |
Description |
This regex matches all valid, current UK Postcodes, including Girobank and non-geographic postcodes, irrespective of whether they contain a space. It does not include overseas territories.
Adapted from the BS7666 postcode rules at: http://www.cabinetoffice.gov.uk/govtalk/schemasstandards/e-gif/datastandards/address/postcode.aspx |
Matches |
M1 1AA | M60 1NW | CR2 6XH | DN55 1PT | W1A 1HQ | EC1A 1BB | GIR 0AA |
Non-Matches |
Q1 1AA | M60 1CW | 5R2 6XH | DJ55 1PT | W1M 1HQ | EC1D 1BB | GIR 1AA |
Author |
Rating:
Ti Marner
|
Source |
|
Your Rating |
|
Title: Re: OK, so it doesn't work
Name: Ti
Date: 5/30/2012 7:44:58 AM
Comment:
The W1M postcode district was re-coded by Royal Mail in 2000 and is no longer a 'valid' postcode (http://www.royalmail.com/sites/default/files/Historical_Info.pdf), I've updated the description accordingly. Hope this helps.
Title: OK, so it doesn't work
Name: Rob
Date: 8/13/2008 10:15:55 PM
Comment:
The problem isn't with the regex, but with the information it is based on.
The code W1M for parts of London exists, despite what the standard actually says. Just do a Google for London w1m to confirm.
Title: doesnot work in vs2005
Name: jayant
Date: 7/28/2008 6:17:52 AM
Comment:
soory but it doesnot work in VS2005. keep giving error whatever postcode one enter.