|
Posted by nemo on 11/29/06 11:59
On Tue, 28 Nov 2006 15:33:34 +0000, Toby Inkster
<usenet200611@tobyinkster.co.uk> wrote:
>GreyWyvern wrote:
>> And lo, Toby Inkster didst speak in alt.html,alt.php,alt.www.webmaster:
>>
>>> For what it's worth, I've written a PHP library that validates and
>>> canonically formats (people in the UK will know how important that is!)
>>> postcodes for the following countries:
>>>
>>> - Canada
>>
>> Can it handle H0H 0H0 ?
>
>Yes -- the parsing for non-UK postcodes is far more rudimentry than for UK
>postcodes. For Canada it just uses the following regular expression on a
>normalised (all uppercase, with whitespace collapsed) postcode to check
>the format is OK:
>
>/^[A-CEGHJ-NPRSTV-Z][0-9][A-CEGHJ-NPRSTV-Z]\s+[0-9][A-CEGHJ-NPRSTV-Z][0-9]$/
>
>Regular expressions for non-UK countries are here:
>http://examples.tobyinkster.co.uk/postcodes/data/intlpc.txt
>
>Columns are:
>
> - ISO 2-character country code, lower case
> - PCRE for valid postcodes
> - optional country prefix for certain European countries
> (the PCRE should match the country-prefixed postcode)
Any chance of your divulging the expression to check for the validity
of format of UK postcodes, please?
[Back to original message]
|