public static boolean checkPass(String s){ System.out.println(s); // Prints : Mypass85 p = Pattern.compile("[A-Za-z]{4}[0-9]{2}"); return p.matcher(s).find(); }