I recently needed to ensure forms on a site I work on used Canadian zip codes as well as US zip + 4. I wanted to remember this regular expression for the future. If you don’t know about zip codes from our neighbors to the north you can look at the wiki page about Canadian zip codes.
Here is the regex I came up with after search stack overflow and a couple of other articles.
Basically it breaks it down into two parts and matches the US zip+4 or the Canadian postal code. Pretty simple but handy to use if you have any need for it.
I want to also include a quick address reg ex, and as I write this I may add more useful regex from time to time.
Here is my address filter regex