RegExLib.com - The first Regular Expression Library on the Web!

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Canadian postal code format verification
Expression
([ABCEGHJKLMNPRSTVXY][0-9][ABCEGHJKLMNPRSTVWXYZ])\ ?([0-9][ABCEGHJKLMNPRSTVWXYZ][0-9])
Description
Accurate Canadian postal code format verification. The format of a Canadian postal code is LDL DLD where L are alpha characters and D are numeric digits. But there are some exceptions. The letters D, F, I, O, Q and U never appear in a postal code because of their visual similarity to 0, E, 1, 0, 0, and V respectively. In addition to avoiding the six "forbidden" letters W and Z also do not appear as the first letter of a postal code (at least not at present).
Matches
M1R 4B0 | L0R 1B1 | L0R1B9
Non-Matches
W1R 4B0 | L0R 1D1 | LOR1B9
Author Rating: The rating for this expression. Vassilis Petroulias
Source
Your Rating
Bad Good

Enter New Comment

Title

Name

Comment

Spammers suck - we apologize. Please enter the text shown below to enable your comment (not case sensitive - try as many times as you need to if the first ones are too hard):

Existing User Comments

Title: Thanks
Name: Fellow Canadian
Date: 11/8/2008 12:18:19 PM
Comment:
Thanks for the regex, I just learned some details about Canadian Postal Codes that I didn't know about the exceptions your account for!


Copyright © 2001-2024, RegexAdvice.com | ASP.NET Tutorials