大小写字母,数字,特殊字符中的至少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#$%"));}}
原文地址:https://www.cnblogs.com/cqbstyx/p/11063278.html
时间: 2024-11-29 11:12:48