密码正则验证:⼤⼩写字母、数字、特殊字符⾄少8位
正则表达式:密码必须包含⼤写字母、数字、特殊字符(四种⾥⾄少三种,且⾄少8位)
写法⼀:
/((^(?=.*[a-z])(?=.*[A-Z])(?=.*\W)[\da-zA-Z\W]{8,16}$)|(^(?=.*\d)(?=.*[A-Z])(?=.*\W)[\da-zA-Z\W]{8,16}$)|(^(?=.*\d)(?=.*[a-z])(?=.*\W)[\da-zA-Z\W]{8,16}$)|(^( =.*\d)(?=.*[a-z])(?=.*[A-Z])[\da-zA-Z\W]{8,}$))/
写法⼆:
/^(?![a-zA-Z]+$)(?![A-Z0-9]+$)(?![A-Z\W_]+$)(?![a-z0-9]+$)(?![a-z\W_]+$)(?![0-9\W_]+$)[a-zA-Z0-9\W_]{8,}$/
正则表达式:密码必须包含⼤写字母、数字、特殊字符且⾄少8位(验证级别⾼)
^(?![A-Za-z0-9]+$)(?![a-z0-9\\W]+$)(?![A-Za-z\\W]+$)(?![A-Z0-9\\W]+$)[a-zA-Z0-9\\W]{8,20}$
使⽤语法
js写法⽰例:
var regexp =new RegExp('^(?![A-Za-z0-9]+$)(?![a-z0-9\\W]+$)(?![A-Za-z\\W]+$)(?![A-Z0-9\\W]+$)[a-zA-Z0-9\\W]{8,20}$');
var newPwd ='AAaa123@@';
if(){
console.log('验证通过');
}else{
console.log('验证不通过');
}
java 写法⽰例:
String regexp ="^(?![a-zA-Z]+$)(?![A-Z0-9]+$)(?![A-Z\\W_]+$)(?![a-z0-9]+$)(?![a-z\\W_]+$)(?![0-9\\W_]+$)[a-zA-Z0-9\\W_]{8,16}$";
if("AAaa1234".matches(PW_PATTERN)){
js正则表达式判断数字System.out.println("匹配成功!");
}else{
System.out.println("匹配失败!");
}

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。