美文网首页
密码必须包含大小写数字正则

密码必须包含大小写数字正则

作者: 爱喝冰红茶 | 来源:发表于2017-08-09 19:43 被阅读0次
public static boolean checkPwd(String pwd){

        if(pwd.matches("^[A-Za-z0-9]{8,32}$")){
            Pattern numPattern =Pattern.compile("[0-9]+");
            Pattern lowerPattern =Pattern.compile("[a-z]+");
            Pattern upperPattern =Pattern.compile("[A-Z]+");
            if(numPattern.matcher(pwd).find() && lowerPattern.matcher(pwd).find() && upperPattern.matcher(pwd).find()){
                return true;
            }
        }
        return false;
    }

相关文章

网友评论

      本文标题:密码必须包含大小写数字正则

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