How to convert input to valid UK postcode format
490959May 2 2011 — edited May 18 2011I want to take a users input and convert it to a valid UK postcode format. Specifically, I want to add in a space in the relevant position, if they have not entered it.
so "G13NU" would be converted to "G1 3NU"
The valid postcode formats are
A0 0AA eg G1 3NU
A00 0AA
A0A 0AA
AA0 0AA
AA00 0AA
AA0A 0AA
Has anyone done similar before, or have any advice?