Datatypes › United Kingdom › Geographic identifiers › postindex

UK postcode

ID gbpostcode

Pattern of postindexNot PIIidentifier

Postcode in the United Kingdom: an outward code (a postcode area of one or two letters and a district of one or two characters) and an inward code (a digit and two letters), usually separated by a space, as in EC1A 1HQ. GIR 0AA and British Forces BFPO numbers are special cases. The regular expression is the one of Google's address metadata.

Pattern of
Postal code/index postindex
Categories
Geographic identifiers
Countries
United Kingdom
Languages
English
W3C DPV
pd:PostalCode
Schema.org
postalCode
Quality
95/100 · missing: translation
Metacrafter rules
2 rules (1 by field name, 1 by value)
Supported by tools
metacrafter, pyWhat, validator.js

Regular expression

^(?:GIR ?0AA|(?:AB|AL|B|BA|BB|BD|BF|BH|BL|BN|BR|BS|BT|BX|CA|CB|CF|CH|CM|CO|CR|CT|CV|CW|DA|DD|DE|DG|DH|DL|DN|DT|DY|E|EC|EH|EN|EX|FK|FY|G|GL|GY|GU|HA|HD|HG|HP|HR|HS|HU|HX|IG|IM|IP|IV|JE|KA|KT|KW|KY|L|LA|LD|LE|LL|LN|LS|LU|M|ME|MK|ML|N|NE|NG|NN|NP|NR|NW|OL|OX|PA|PE|PH|PL|PO|PR|RG|RH|RM|S|SA|SE|SG|SK|SL|SM|SN|SO|SP|SR|SS|ST|SW|SY|TA|TD|TF|TN|TQ|TR|TS|TW|UB|W|WA|WC|WD|WF|WN|WR|WS|WV|YO|ZE)\d[\dA-Z]? ?\d[ABD-HJLN-UW-Z]{2}|BFPO ?\d{1,4})$

Python re syntax.

Test a value

Examples

ValueDescription
EC1Y 8SY
M2 5BQ
CR0 2YR
DN16 9AA
W1A 4ZZ
GIR 0AA
BFPO 61
12345 invalid digits only
EC1Y 8SI invalid the letter I is not used in the inward code

Sources

Use this record