Validating uk postcodes

SELECT @b Valid = 1 WHERE @str Post Code LIKE '[A-Za-z][A-Za-z][0-9][0-9][0-9][A-Za-z][A-Za-z]'OR @str Post Code LIKE '[A-Za-z][A-Za-z][0-9][A-Za-z][0-9][A-Za-z][A-Za-z]'OR @str Post Code LIKE '[A-Za-z][0-9][0-9][0-9][A-Za-z][A-Za-z]'OR @str Post Code LIKE '[A-Za-z][A-Za-z][0-9][0-9][A-Za-z][A-Za-z]'OR @str Post Code LIKE '[A-Za-z][0-9][0-9][A-Za-z][A-Za-z]'OR @str Post Code LIKE '[A-Za-z][A-Za-z][0-9][0-9]'OR @str Post Code LIKE '[A-Za-z][0-9][0-9]'OR @str Post Code LIKE '[A-Za-z][A-Za-z][0-9]'OR @str Post Code LIKE '[A-Za-z][0-9]'RETURN @b Validre: Validate UK postcode You can formulate your Regex for the LIKE in this format...SELECT @b Valid = 1 WHERE @str Post Code LIKE '[A-Za-z][A-Za-z][0-9][0-9][0-9][A-Za-z][A-Za-z]'OR @str Post Code LIKE '[A-Za-z][A-Za-z][0-9][A-Za-z][0-9][A-Za-z][A-Za-z]'OR @str Post Code LIKE '[A-Za-z][0-9][0-9][0-9][A-Za-z][A-Za-z]'OR @str Post Code LIKE '[A-Za-z][A-Za-z][0-9][0-9][A-Za-z][A-Za-z]'OR @str Post Code LIKE '[A-Za-z][0-9][0-9][A-Za-z][A-Za-z]'OR @str Post Code LIKE '[A-Za-z][A-Za-z][0-9][0-9]'OR @str Post Code LIKE '[A-Za-z][0-9][0-9]'re: Validate UK postcode Really?

Fox Stuff is maintained by Mike Lewis Consultants Ltd. Feel free to download and use any code or components, and to pass around copies of the articles (but please do not remove our copyright notices or disclaimers). I am trying to create validation for a UK postcode.I have found what I believe will do the job (see below), but I do not know what other lines I need to enter to complete the process. \d)$/ There is a postal codes validation Reg Ex on this PDF released by the UK government: https://uk/government/uploads/system/uploads/attachment_data/file/488478/Bulk_Data_Transfer_-_additional_validation_valid_from_12_November_2015I'd advise anyone arriving here from search engines to avoid the regex in the above comment (it's perhaps typical that the UK government would be using a badly formed regex) because it doesn't match a lot of valid postcodes (e.g.Hi, Im running the below macro for validating and reformatting UK postcodes but the issue I'm having is any postcode that starts with one alpha character and one numeric followed by space then 1 numeric and two alpha character's keeps getting marked as invalid when its not. the only UK postcodes which have just one alpha character in the first portion of the postcode is W, N, E, L, B & M so these will have one alpha character followed by 1 or 2 numeric then a space as above.

Leave a Reply