Start a new topic

Inserting a space into a UK or Canadian postal codes

An ImportOmatic user recently suggested adding a function to format UK postal codes, adding a space when necessary. Fortunately, this is easily done using ImportOmatic's Regex Dictionary functionality. This RegEx dictionary should do the trick (if I fully understood Wikipedia's UK postal code entry):


Here is the dictionary export that you can import directly to your own dictionary:

$1 $2 ^(\w{3})(\w{3})$ TRUE
$1 $2 ^(\w{4})(\w{3})$ TRUE
$1 $2 ^(\w{2})(\w{3})$ TRUE

For Canadian addresses, try this in your "Value to match on":  ^([A-Z])([0-9])([A-Z])([0-9])([A-Z])([0-9])$

1 Comment

Brilliant! We've been trying to crack this for ages (well, on and off), and had resigned ourselves to tidying them pre-import with an Excel formula.

Getting postcodes on in the correct format is important not just for postal reasons (or geodemographic profiling, etc), but also for submitting Gift Aid claims to HMRC.  Incorrectly spaced postcodes cause exceptions in the online submission process, and mean we have to start all over again, so this will help us save time and make sure are claiming all the Gift Aid we can.

Thank you! :-) 

Login or Signup to post a comment