Created
March 17, 2022 10:59
-
-
Save peteeveleigh/1b15442fa8cc5045824ddcea87dc805b to your computer and use it in GitHub Desktop.
Revisions
-
peteeveleigh created this gist
Mar 17, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ {# These are the valid UK postcode formats according to https://ideal-postcodes.co.uk/guides/uk-postcode-format #} {% set zipCodes = [ 'AA9A 9AA', 'A9A 9AA', 'A9 9AA', 'A99 9AA', 'AA9 9AA', 'AA99 9AA' ] %} {% for zipCode in zipCodes %} {# Normalise zipcode, remove spaces, make uppercase Remove last 3 characters and return the remainder #} {{ zipCode }} - {{ zipCode|replace({' ':''})|upper|slice(0,-3) }} {% endfor %}