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

Category: Strings

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:

Rate This Regex
Sending
User Review
0 (0 votes)

Expression Flags

Flags Description
i Ignore case sensitive.
g Allows global search.
m Allows multiline search.