As I say, a first stab to get the ball rolling. Tim asked for a PC validator: is that to validate that the Post Code actually exists, or validate it's structure so that it could possibly exist? You can't assume that the user enters in upper case, unless you force it before validating.
I agree, a straight look up would be more accurate. Perhaps there's a web service to check post codes. Perhaps, though, this is overkill for what Tim is wanting here. Douglas -----Original Message----- From: Paul Johnston [mailto:[EMAIL PROTECTED]] Sent: 27 January 2003 13:03 To: [EMAIL PROTECTED] Subject: RE: [ cf-dev ] Postcode validation Hmmm... Regex: > > This is a first stab at one... > > RegEx = ^[a-zA-Z]{1,2}[1-9]{1,2}[ ]{1}[1-9]{1,2}[a-zA-Z]{1,2}& Wouldn't work for something like SW1P Which is a Westminster postcode Adding this in it is slightly more complicated (and therefore more easy to hack), Postcodes are always upper case too: RegEx = ^[A-Z]{1,2}[1-9][0-9A-Z]?[ ]{1}[1-9]{1,2}[A-Z]{1,2}& Unfortunately, this also equals: XX1X which is definitely not a postcode Goes back to my original statement that you need to actually have a list of postcodes to test against, which means buying the postcode database from the Royal Mail. The only way to really make a postcode that isn't going to be hackable is to have all of the postcodes! It's not a string that can be simply tested with a regular expression (although it can be verified as a POSSIBLE postcode) Paul -- ** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] For human help, e-mail: [EMAIL PROTECTED] -- ** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] For human help, e-mail: [EMAIL PROTECTED]
