Test, validate and match regular expressions
This regex validates Canadian postal codes, matching the standard format of alternating letters and digits (e.g., A1A 1A1) with an optional space or no space between the two triads. It is case-insensitive and enforces exact length and structure, making it ideal for form validation, address parsing, and data cleansing in applications that require Canadian mailing addresses.