密码的校验.大小写字母,数字,特殊字符中的至少3种

大小写字母,数字,特殊字符中的至少3种.8位以上,正确返回true
public static boolean rexCheckPassword(String input) {
// 8-20 位,字母、数字、字符
String regStr = "^(?![a-zA-Z]+$)(?![A-Z0-9]+$)(?![A-Z\\W_]+$)(?![a-z0-9]+$)(?![a-z\\W_]+$)(?![0-9\\W_]+$)[a-zA-Z0-9\\W_]{8,20}$";
return input.matches(regStr);
}

@Test
public static void main(String[] args){
System.out.println(rexCheckPassword("abcd"));
System.out.println(rexCheckPassword("abcd1234"));
System.out.println(rexCheckPassword("abcd1234#"));
System.out.println(rexCheckPassword("Abcd1234"));
System.out.println(rexCheckPassword("Abcd#$%"));
}}
posted @ 2019-06-21 10:47  ricky0001  阅读(7254)  评论(0编辑  收藏  举报