Hacker News new | past | comments | ask | show | jobs | submit login

And the regex to validate this is a monster, even noting that this still allows bad input:

  (GIR 0AA)|((([A-Z-[QVX]][0-9][0-9]?)|(([A-Z-[QVX]][A-Z-[IJZ]][0-9][0-9]?)|(([A-Z-[QVX]][0-9][A-HJKSTUW])|([A-Z-[QVX]][A-Z-[IJZ]][0-9][ABEHMNPRVWXY])))) [0-9][A-Z-[CIKMOV]]{2})
http://stackoverflow.com/questions/164979/uk-postcode-regex-...



The UK Government (after OSM took off) started to open source and release more data. You can download[1] the database of most of the UK postcodes[2] and their latitude & longitude. So if you want to really verify a GB postcode, you can just check it against the list

[1] It's called 'Code Point Open' and you can 'order' it (for free) here http://www.ordnancesurvey.co.uk/business-and-government/prod...

[2] It's most of UK. It doesn't include Northern Ireland




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: