We are using the UK government provided regular expression, taken from wikipedia[*], with few modifications:
1. We expect all letters to be uppercase.
2. We allow ZZ99 postcodes, which do not follow guidelines, e.g. allows CIMKOV characters in the second part.
3. We drop GIR 0AA as a valid postcode, we don't expect receiving files with such postcode.
4. We allow 0 - 3 spaces between parts.
5. We allow outward code, without second part.
6. On the last "or" part of the first part making number non-optional.
7. We don't allow CIMKOV letters in the second part.
[*] https://en.wikipedia.org/wiki/Postcodes_in_the_United_Kingdom#Validation
Everything prior to the Town in the Address
http://www.datadictionary.nhs.uk/data_dictionary/attributes/c/cou/country_code_de.asp
From National MIM
Home
Postal
Temporary