Martin Ebourne wrote:
On Thu, 2008-01-17 at 11:01 -0800, Michael G Schwern wrote:
Or, ya know, Canadians.  Damn Canadians with their alphanumeric postal codes!!

Here's a "do you mind if I tell you how we [uhh, they] do it in Canada" 
moment...

Canadian Postal Codes are decidedly non-hateful. They avoided the issue of confusing 0 and O, and 1 and I by alternating alphas and numerics. It's always A0A 0A0. Furthermore, they disallow D, I, O, F and Q to make OCR easier and further reduce human confusion. I guess F looks like the 7 with a line through it? This gives them something like 7.2 million codes.

Not so unusual really, in the UK postcodes are of the form B27 6EG where
the first part is one or two letters for the local city, and a number
for district (numbered in alphabetical order, except for 1 which is
always the centre of town). The second part is always 1 digit and 2
letters to denote the street or building.

There's exceptions.  For example, SW1A 0AA is the House of Commons.

They made the mistake of including O and 0 resulting in CR0 (central Croydon) vs CRO (not sure what that is) confusion. And the critical alternating alphanumerics is key to not mixing up numbers and letters that look alike.

Wikipedia provides a fun validating regex for the common case:
[A-Z]{1,2}[0-9R][0-9A-Z]? [0-9][A-Z-[CIKMOV]]{2}

And the complete case:
(GIR 0AA|[A-PR-UWYZ]([0-9]{1,2}|([A-HK-Y][0-9]|[A-HK-Y][0-9]([0-9]|[ABEHMNPRV-Y]))|[0-9][A-HJKS-UW]) [0-9][ABD-HJLNP-UW-Z]{2})

Which means sometimes they disallow Q and sometimes they disallow I but always allow O. Guh.


--
191. Our Humvees cannot be assembled into a giant battle-robot.
    -- The 213 Things Skippy Is No Longer Allowed To Do In The U.S. Army
           http://skippyslist.com/?page_id=3

Reply via email to