Displaying page
of
pages;
Items to
Title |
Test
Details
Canada Postal Codes
|
Expression |
^(?<full>(?<part1>[ABCEGHJKLMNPRSTVXY]{1}\d{1}[A-Z]{1})(?:[ ](?=\d))?(?<part2>\d{1}[A-Z]{1}\d{1}))$
|
Description |
This is a combination of Jerry Schmersahl's (http://regexlib.com/REDetails.aspx?regexp_id=930) US ZIP Code regex and John Alpha's (http://regexlib.com/REDetails.aspx?regexp_id=2754) Canadian Postal Code regex.
It takes a Canadian postal code with or without a space and matches the first three digits to the named reference 'part1', the second three digits to the named reference 'part2', and the entire code (if a match) to the named reference 'full'
|
Matches |
M4S 1G9 | M4S1G9 | K1A0B1 | K1A 0B1
|
Non-Matches |
123 ABC | 5A2A2B | K1A 0B | M4S | 90210
|
Author |
Rating:
Christopher Congdon
|
Displaying page
of
pages;
Items to