Regular Expressions 101

Community Library

Community Library Entry

-1

Regular ExpressionOpen Workspace

/
\b(GIR ?0AA|(?:[A-PR-UWYZ](?:\d{0,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})\b
/
gmi

Description
Created·2015-04-10 22:38
Type·Match
Flavor·JavaScript

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

Submitted by Ti Marner
Open Workspace