regex for canadian postal code
im trying to validate a canadian postal code using regex but i dont know that correct syntax..
can someone please help me ..thanks in advance
here is my code .. (postal code is letter number letter space number letter numberex R5Y 1E3)
String regex;
Pattern pattern;
Matcher matcher;
regex = "[A-Z][0-9][A-Z] [0-9][A-Z][0-9]";
pattern = Pattern.compile(regex);
if(! pattern.matcher(param).matches())
[457 byte] By [
Picard] at [2007-9-30 21:57:29]

[A-Z] isn't correct for the first character, for a start. I know for sure that "I" and "O" can't appear there, and I don't think they can appear in the other letter positions either. I also know that there aren't any postal codes starting with U or W or Y or Z, and there are probably others. I guess it depends how picky you want to get.
That's what I thought too, so I looked there. I found a PDF document for download about addressing standards, but I didn't download it. Here's a link that I did find, which looks practical enough for the OP's needs: http://mindprod.com/jgloss/postalcode.html