Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs 密码强度问题:regex_Angularjs_Regex - Fatal编程技术网

Angularjs 密码强度问题:regex

Angularjs 密码强度问题:regex,angularjs,regex,Angularjs,Regex,标记 <form ng-submit="doRegister(registerForm);" novalidate name="registerForm"> <input type="password" name="Password" ng-model="register.Password" ng-pattern="/^.*(?=.{3,})(

标记

<form ng-submit="doRegister(registerForm);" novalidate name="registerForm">
    <input type="password" name="Password" ng-model="register.Password" 
        ng-pattern="/^.*(?=.{3,})(?=.*[a-zA-Z])(?=.*[0-9])(?=.*[\d\X])(?=.*[!$#%]).*$/"/>
    <span ng-show="registerForm.Password.$error.pattern" class="help-block">
        min 1 lower char, 1 upper char, 1 digit and one special char 
    </span>
    
    <button type="submit" ng-disabled="registerForm.$invalid" >
        Submit
    </button>
</form>

最少1个低位字符、1个高位字符、1个数字和一个特殊字符
提交
我正在测试密码强度,最小值为1个低位字符、1个高位字符、1个数字和一个特殊字符

我正在测试这个字符串:a1A@s.com//失败

我正在测试这个字符串: 12345aA//通过


我做错了什么吗?

它失败了,因为在上一次前瞻中,
@
不是角色类的一部分。您还可以将正则表达式简化为:

/^(?=.*[a-z])(?=.*[a-z])(?=.*[0-9])(?=.*[@!$#%]).{3,}$/

它失败了,因为
@
不是上次前瞻中角色类的一部分。您还可以将正则表达式简化为:

/^(?=.*[a-z])(?=.*[a-z])(?=.*[0-9])(?=.*[@!$#%]).{3,}$/

第一个测试用例的失败是故意的吗?因为我确实看到了它与您的标准不匹配,所以请查看zxcvbn,一个更好的密码强度验证器。@Geoff:请详细解释一下zxcvbn@Toto当前位置仔细阅读此处的问题。你多么粗心地把它标成了复制品!!!!我的问题regex参数与那个问题完全不同!!!第一个测试用例的失败是故意的吗?因为我确实看到了它与您的标准不匹配,所以请查看zxcvbn,一个更好的密码强度验证器。@Geoff:请详细解释一下zxcvbn@Toto当前位置仔细阅读此处的问题。你多么粗心地把它标成了复制品!!!!我的问题regex参数与那个问题完全不同
(?=.[a-zA-Z])
应该被
(?=.[a-Z])(?=.[a-Z])
替换。你说得对,我刚刚注意到
有问题的
一个下半部分,一个上半部分。
(?=.[a-zA-Z])(?=.[a-Z])(?=.[a-Z])(?=.[a-Z])
有问题的部分。