判断密码中必须含有大写字母,小写字母,数字和特殊字符,至少三种
private static boolean getMatch(String str){ int count=0; Pattern p1 = Pattern.compile("[A-Z]"); if(p1.matcher(str).find()){ count++; } Pattern p2 = Pattern.compile("[a-z]"); if(p2.matcher(str).find()){ count++; } Pattern p3 = Pattern.compile("[0-9]"); if(p3.matcher(str).find()){ count++; } Pattern p4 = Pattern.compile("[^a-zA-Z0-9]"); if(p4.matcher(str).find()){ count++; } if(count>=3){ return false; }else{ return true; } }