Strict Canadian Postal Code Validation Regular Expression

This regular expression can be used to strictly match and validate Canadian postal codes (cannot start with W or Z and cannot contain the letters D, F, I, O, Q, or U).

Postal codes in Canada do not include the letters D, F, I, O, Q, or U, as the optical character recognition (OCR) equipment used in automated sorting could easily confuse them with other letters and digits. The letters W and Z are used but are not currently used as the first letter. The Canadian Postal Codes use alternate letters and numbers (with a space after the third character) in this format: A9A 9A9.



  • A9A 9A9
  • N7S 0B1
  • X0G 0A0


  • A9A9A9
  • W9A 9A9
  • Z9A 9A9

See Also: