Title: New Revision of above regex
Date: 5/1/2007 6:20:31 AM
I found that none of the examples have worked for me (there always seems to be a valid postcode that they think is invalid) so I have rewritten it, and it seems to work fine now. it may need lower case capability added though.
Title: GovTalk's RegExp
Date: 10/30/2005 4:59:44 AM
gov talk have provided a regex of their own here:
Title: Pedro, try this
Date: 4/16/2005 6:36:54 AM
Try this expression to match just the first part
Title: Quite good
Date: 4/16/2005 6:35:19 AM
A useful simple validator, but it still accepts a lot of invalid postcodes. I tried the most recent post version of this and it still accepted about 157 invalid postcodes in my test data, out of about 1423 invalid total, so it's about 90% efficient.
Title: validate first part only
Name: Pedro Costa
Date: 4/14/2005 5:47:00 AM
i'm not very experienced in regular expressions how can i split this one to only validate the first part of the post code, e.g. GIR or SW1Y?
Title: Removed More Groups
Name: Kevin Watkins
Date: 3/29/2005 8:53:50 AM
Just realised I can remove some more groups from the regex... Try:
Title: Problems With B77 3BS
Name: Kevin Watkins
Date: 3/29/2005 8:48:22 AM
I had some problems with the valid postcode 'B77 3BS' - it would only match the B77 part. Here is a corrected regex:
I've also removed some unnecessary groups and made the other groups non-capturing to speed it up.
Date: 1/26/2005 10:04:54 AM
Title: Problems resolved
Date: 12/6/2004 7:32:53 AM
The problems the original expression has with N1 for example don't occur with the modified version I have quoted above which is correct to the UK Government Data Standards at:
Title: some unexpected problems
Date: 10/7/2004 11:26:35 AM
This doesn't allow for some postcodes eg N1 in London which are valid.
Title: Postcode extra characters
Date: 6/23/2004 8:28:53 AM
A slight tweak to stop extra characters after the postcode i.e. Q1 1AAA. Otherwise it behaves the same, hopefully.