当前位置: 代码迷 >> 综合 >> 大小写字母,数字,特殊字符中的至少3种.8位以上,正确返回true
  详细解决方案

大小写字母,数字,特殊字符中的至少3种.8位以上,正确返回true

热度:89   发布时间:2023-09-14 14:07:44.0
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#$%"));
}}
  相关解决方案