Regular Expression To Match US/UK/CA Zip (Postal) Codes

A general regular expression to verify postal codes (zip codes) in the United States, Britain, and Canada.

/^(\d{5}((|-)-\d{4})?)|([A-Za-z]\d[A-Za-z][\s\.\-]?(| -)\d[A-Za-z]\d)|[A-Za-z]{1,2}\d{1,2}[A-Za-z]? \d[A-Za-z]{2}$/

Matches:

  • 12345
  • 12345-6789
  • TS19 0AP
  • V9A 7N2

Non-matches:

  • 123457
  • 12345-67890
  • TS19 0AP0
  • V9AA 7N2

See Also: