You are here: Re: Need world zip codes « All PHP « IT news, forums, messages
Re: Need world zip codes

Posted by Toby Inkster on 11/28/06 15:33

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)

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация