Difference between revisions of "Postcodes"
From Leaky
(Created page with "Postcode validation by regex: if ($postcode =~ /^([A-PR-UWYZ][0-9][0-9]?|[A-PR-UWYZ][A-HK-Y][0-9][0-9]?|[A-PR-UWYZ][0-9][A-HJKPSTUW]|[A-PR-UWYZ][A-HK-Y][0-9][ABEHMNPRVWXY])...") |
(No difference)
|
Latest revision as of 09:21, 16 October 2020
Postcode validation by regex:
if ($postcode =~ /^([A-PR-UWYZ][0-9][0-9]?|[A-PR-UWYZ][A-HK-Y][0-9][0-9]?|[A-PR-UWYZ][0-9][A-HJKPSTUW]|[A-PR-UWYZ][A-HK-Y][0-9][ABEHMNPRVWXY]) ?([0-9][ABD-HJLNP-UWXYZ]{2})$/i) { $postcode = uc("$1 $2"); } else { # postcode invalid format }
Latest ONS Postcode Directory download can be found here:
Easy HTTP API to reference ONS data: