Skip to content

Instantly share code, notes, and snippets.

@YohannParis
Created September 10, 2019 17:29
Show Gist options
  • Save YohannParis/a2fa8882745c138f360ce35c50980d7f to your computer and use it in GitHub Desktop.
Save YohannParis/a2fa8882745c138f360ce35c50980d7f to your computer and use it in GitHub Desktop.
[regex] Canada postal code, strict.
/**
* Regular expression to test string is a proper Canadian postal code.
* H0H H0H, H0H0H0, H0H-H0H, and h0h0h0 formats are valid.
*/
/^[ABCEGHJ-NPRSTVXY][0-9][ABCEGHJ-NPRSTV-Z][ -]?[0-9][ABCEGHJ-NPRSTV-Z][0-9]$/i
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment