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

Please support RegExLib Sponsors

Sponsors

Expressions by User

   Displaying page 1 of 1 pages; Items 1 to 1
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: The rating for this expression. Christopher Congdon
   Displaying page 1 of 1 pages; Items 1 to 1

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