UK Postcode Validation Regex

So, the Government offer us a regex to validate UK postcodes. According to Wikipedia it should be:

^([Gg][Ii][Rr] 0[Aa]{2})|((([A-Za-z][0-9]{1,2})|(([A-Za-z][A-Ha-hJ-Yj-y][0-9]{1,2})|(([A-Za-z][0-9][A-Za-z])|([A-Za-z][A-Ha-hJ-Yj-y][0-9]?[A-Za-z])))) [0-9][A-Za-z]{2})$

Nice. That’s not complicated, is it? Continue reading “UK Postcode Validation Regex”

Advertisements
UK Postcode Validation Regex