|
Posted by nemo on 11/30/06 11:52
On Wed, 29 Nov 2006 23:05:49 +0000, Toby Inkster
<usenet200611@tobyinkster.co.uk> wrote:
>nemo wrote:
>
>> Any chance of your divulging the expression to check for the validity
>> of format of UK postcodes, please?
>
>I did post the entire source code earlier, but if you'd like an all-in-one
>regexp, then you could do a lot worse than...
>
>/([A-PR-UWYZ][A-HK-Y]?([0-9]{1,2}|[1-9][A-HJKMNPR-Y])\s+[0-9][ABDEFGHJLN
>P-UW-Z]{2})|(BFPO\s+(c..?o\s+)?([0-9]{1,4}))|(GIR\s+0AA)|(SAN\s+TA1)|((
>(ASCN)|(BBND)|(BIQQ)|(FIQQ)|(PCRN)|(SIQQ)|(STHL)|(TDCU)|(TKCA))\s+1ZZ)/
>
>You'll need to remove the line breaks -- this regexp should contain no
>white space. Note that this allows any amount of white space between
>outgoing and incoming parts of the postcode (e.g. 'AB10 1AB' and
>'AB10 1AB' both pass the test. It's a fairly trivial matter to collapse
>that down if required.
>
>This is untested, but compiled from several that I do use.
Thank you.
[Back to original message]
|