Canada zip code format regex

Effective regular expression to validate Canada zip code format : String regex = "^(?!.*[DFIOQU])[A-VXY][0-9][A-Z] ?[0-9][A-Z][0-9]$"; Pattern pattern = Pattern.compile(regex); if(!pattern .matcher("postcode").matches()) {         System.out.println("This is CA zip code"); }

Advertisements