On Tue, Apr 01, 2003 at 11:47:55AM +0100, Jon Reades wrote: > So far my regex looks like this (using the {} notation for consistency > and readability): > > m/[A-Z]{1,2}\d{1,2}[A-Z]{0,1}\W\d{1,1}[A-Z]{2,2}/
Works for my list of postcodes here (except, I can only match the gross code - the first bit - so I deleted everything \W and onwards). It's all the gross codes in the country (well, pretty much) so it's not bad as far as real-life tests goes.. > Of course, it doesn't tell me if this is a rule, or just a general > statement of fact, but that could presumably help in validating > addresses using a regex. However, I'm not sure if it's really worth the > additional effort and complexity in the regex to include this. Unlikely. We validate our postcodes against a database (actually, we use it to look up airports/depots in a dispatch system), but they're not all there. It seems that they just up the numbers mostly when they need new areas though, so I wouldn't worry too much about it breaking in the long term. It does suffer from the e-mail "not valid until it's been sent there successfully" syndrome though. Cheers, Alex.