美文网首页
大小写字母,数字,特殊字符中的至少3种.8位以上,正确返回tru

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

作者: 香山上的麻雀 | 来源:发表于2019-11-30 17:20 被阅读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#$%"));
}}

相关文章

网友评论

      本文标题:大小写字母,数字,特殊字符中的至少3种.8位以上,正确返回tru

      本文链接:https://www.haomeiwen.com/subject/grnowctx.html