Build, test, and debug regular expressions
This regex validates US ZIP codes and Canadian postal codes. The first alternative matches 5-digit US ZIPs with an optional ZIP+4 extension (e.g., 12345 or 12345-6789). The second matches Canadian postal codes in the A1A 1A1 format, restricting the first letter to valid Canadian characters (excluding D, F, I, Q, U, W, Z) and allowing an optional space separator. Ideal for address validation forms on North American e-commerce or shipping websites.