1 一步到位正则表达式:
(?=.*[0-9])(?=.*[a-z])(?=.*[!@#$%^&*])(?=.*[A-Z]).{6,16}
2这是穷举法写的正则:
$a = '[a-z]+';
$b = '[0-9]+';
$c = '[-+_!@#$%^&*()]+';
$p = "/$a$b$c|$a$c$b|$b$a$c|$b$c$a|$c$a$b|$c$b$a/";
3这是一个用js方法写的验证:
var strPassword =document.getElementById("user_userpass").value;
var num=0;
if(strPassword.search(/[A-Z]/)!=-1)
{
num+=1;
}
if(strPassword.search(/[0-9]/)!=-1)
{
num+=1;
}
if(strPassword.search(/[a-z]/)!=-1)
{
num+=1;
}
if(strPassword.search(/[^A-Za-z0-9]/)!=-1)
{
num+=1;
}
if(num>=2 && (strPassword.length>=6 && strPassword.length<=16 ))
{
alert(“y”);
}
else
{
alert(“n”);
}
(?=.*[a-zA-Z])(?=.*[\d])[\w\W]{6,16}