Canadian postal code regex

62 views
Skip to first unread message

Liam Morland

unread,
Jan 7, 2013, 1:38:41 PM1/7/13
to geon...@googlegroups.com
In this file:
http://download.geonames.org/export/dump/countryInfo.txt
the Canadian postal code regex is shown as:

^([a-zA-Z]\d[a-zA-Z]\d[a-zA-Z]\d)$

There ought to be a space between the first three and last three characters. This is correctly done in the postal code format: "@#@ #@#".

Some letters are not used in Canadian postal codes, so a better regex is this:

^([ABCEGHJKLMNPRSTVXY]\d[ABCEGHJKLMNPRSTVWXYZ]) ?(\d[ABCEGHJKLMNPRSTVWXYZ]\d)$

Marc Wick

unread,
Jan 9, 2013, 3:11:23 PM1/9/13
to geon...@googlegroups.com
Hi Liam

Thanks. The regex has been changed.

Best Regards

Marc
> --
> You received this message because you are subscribed to the Google
> Groups "GeoNames" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/geonames/-/L6APm0-Zdb4J.
> To post to this group, send email to geon...@googlegroups.com.
> To unsubscribe from this group, send email to
> geonames+u...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/geonames?hl=en.
Reply all
Reply to author
Forward
0 new messages