if(StringUtil.isNotBlank(newPassword)){
//验证长度
if (newPassword.trim().length()<8) {
throw new BaseAppException("密码长度必须为8位以上!");
}
//验证字母、数字、特殊符号两种或以上组成
Pattern pwdFormat = Pattern.compile("(?!^(\\d+|[a-zA-Z]+|[~!@#$%^&*?]+)$)^[\\w~!@#$%\\^&*?]+$");
Matcher matcherFormat = pwdFormat.matcher(newPassword);
Boolean flagFormat = matcherFormat.matches();
if(!flagFormat){
throw new BaseAppException("密码必须包含字母、数字或特殊字符两种及以上!");
}
}
转载于:https://my.oschina.net/zhangshsURL/blog/1581628