$password = 'pwd3000!';
if(!preg_match('/^(?=.{4,31}$)(?!.*(.)\1{4}). \w[\w.-]+\w$/', $password)){
echo 'Your password is too easy';
} else {
echo 'Your password is strong';
}
如果密码有超过4个重复字符,我想回复'您的密码太容易了#39;
现在,当我运行代码时,我得到的密码太容易了#39;但它只是字符串中的3个重复字符,而不是4.如何解决此问题?
答案 0 :(得分:1)
试试这个:
$password = "aaaabb";
if (preg_match('/(\w)\1{3,}/', $password)) {
echo 'Your password is too easy';
} else {
echo 'Your password is strong';
}
输出:
Your password is too easy