Validating date c
However, we're going to have to investigate exactly what the rules are, as the various solutions listed above appear to apply different rules as to which letters are allowed.After some research, we've found some more information.You can't expect what is there currently to be true forever.As an example, in 1990, the Post Office decided that Aberdeen was getting a bit crowded.It's part of the process for obtaining permission to build; local authorities are obliged to keep this updated with the Post Office (not that they all do).Furthermore, as noted by a number of other users, there's the special postcodes such as Girobank, GIR 0AA, and the one for letters to Santa, SAN TA1 - you probably don't want to post anything there but it doesn't appear to be covered by any other answer.
Anything that validates a "UK" postcode will also validate the postcodes of a number of other countries.
I finally found one that validates with all, using the new regex provided by the government: https://uk/government/uploads/system/uploads/attachment_data/file/413338/Bulk_Data_Transfer_-_additional_validation_valid_from_March_2015It isn't in any of the previous answers so I post it here in case they take the link down: An old post but still pretty high in google results so thought I'd update. [0-9][a-zA-Z]) I've been looking for a UK postcode regex for the last day or so and stumbled on this thread.
This Oct 14 doc defines the UK postcode regular expression as: ^([Gg][Ii][Rr] 0[Aa])|((([A-Za-z][0-9])|(([A-Za-z][A-Ha-h J-Yj-y][0-9])|(([AZa-z][0-9][A-Za-z])|([A-Za-z][A-Ha-h J-Yj-y][0-9]? I worked my way through most of the suggestions above and none of them worked for me so I came up with my own regex which, as far as I know, captures all valid UK postcodes as of Jan '13 (according to the latest literature from the Royal Mail).
Contraint - ABEHMNPRVWXY Second half of postcode Valid formats [0-9][A-Z][A-Z] Exceptions Position - Second and Third.
Contraint - CIKMOV not used Most of the answers here didn't work for all the postcodes I have in my database.Postcodes are arbitrarily complex and constantly changing.