^[A-Z]\d[A-Z][ ]?\d[A-Z]\d$
http://stackoverflow.com/a/11149740[^]A regex approach can validate the format of a Canadian postcode, but it's not sufficient to guarantee that the postcode actually exists. For example: A9A 0A0 looks like a valid Canadian postcode, but the forward sortation area A9A doesn't actually exist. Are you sure you wouldn't rather do some kind of lookup against an official list of postcodes?
A regex approach can validate the format of a Canadian postcode, but it's not sufficient to guarantee that the postcode actually exists.
For example: A9A 0A0 looks like a valid Canadian postcode, but the forward sortation area A9A doesn't actually exist.
A9A 0A0
A9A
Are you sure you wouldn't rather do some kind of lookup against an official list of postcodes?
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)