此 webApi PasswordValidator 的等效正则表达式
Equivalent regex for this webApi PasswordValidator
我想在使用正则表达式提交表单之前验证密码,我想知道以下 PasswordValidator 设置的等效正则表达式是什么:
UserManager.PasswordValidator = new PasswordValidator
{
RequiredLength = 6,
RequireNonLetterOrDigit = true,
RequireDigit = false,
RequireLowercase = true,
RequireUppercase = true,
};
我正在使用 AngujarJS 模式验证。
示例:
<input type="password" class="form-control" name="inputPassword" ng-minlength="6" np-pattern="/^(?=.*[a-z])(?=.*[A-Z])(?=.*(_|[^\w])).+$/" ng-model="userData.Password" />
<p class="alert-danger" ng-show="userDetails.inputPassword.$error.pattern">The Password is invalid</p>
但它只是忽略它。
非常感谢!
更新 1
在接受的答案的帮助下,我得出以下正则表达式 ^(?=.[a-z])(?=.[A-Z])(?=.*(_|[^\ w])).+$ 并将长度验证添加为 ng-minlength="6" 由于某种原因,模式验证在 IE9 上不起作用,验证阻止用户保存,使其完全无用。
更新 2
根据 stribizhev 的建议,将任何符号正则表达式更改为 (?=.*[\W_]) 固定 IE9 验证,因此它在 IE9 中 100% 工作,最终代码是
<input type="password" class="form-control" name="inputPassword" ng-minlength="6" ng-pattern="/^(?=.*[a-z])(?=.*[A-Z])(?=.*[\W_]).+$/" ng-model="userData.Password" />
<p class="alert-danger" ng-show="userDetails.inputPassword.$error.pattern || userDetails.inputPassword.$error.minlength">The Password is invalid</p>
非常感谢大家
^(?=.*[!@#$&*])(?=.*[a-z])(?=.*[A-Z]).{6,}$
我在 SO 上找到了答案,它会提示您如何构建自己的正则表达式
我想在使用正则表达式提交表单之前验证密码,我想知道以下 PasswordValidator 设置的等效正则表达式是什么:
UserManager.PasswordValidator = new PasswordValidator
{
RequiredLength = 6,
RequireNonLetterOrDigit = true,
RequireDigit = false,
RequireLowercase = true,
RequireUppercase = true,
};
我正在使用 AngujarJS 模式验证。 示例:
<input type="password" class="form-control" name="inputPassword" ng-minlength="6" np-pattern="/^(?=.*[a-z])(?=.*[A-Z])(?=.*(_|[^\w])).+$/" ng-model="userData.Password" />
<p class="alert-danger" ng-show="userDetails.inputPassword.$error.pattern">The Password is invalid</p>
但它只是忽略它。
非常感谢!
更新 1 在接受的答案的帮助下,我得出以下正则表达式 ^(?=.[a-z])(?=.[A-Z])(?=.*(_|[^\ w])).+$ 并将长度验证添加为 ng-minlength="6" 由于某种原因,模式验证在 IE9 上不起作用,验证阻止用户保存,使其完全无用。
更新 2
根据 stribizhev 的建议,将任何符号正则表达式更改为 (?=.*[\W_]) 固定 IE9 验证,因此它在 IE9 中 100% 工作,最终代码是
<input type="password" class="form-control" name="inputPassword" ng-minlength="6" ng-pattern="/^(?=.*[a-z])(?=.*[A-Z])(?=.*[\W_]).+$/" ng-model="userData.Password" />
<p class="alert-danger" ng-show="userDetails.inputPassword.$error.pattern || userDetails.inputPassword.$error.minlength">The Password is invalid</p>
非常感谢大家
^(?=.*[!@#$&*])(?=.*[a-z])(?=.*[A-Z]).{6,}$
我在 SO 上找到了答案,它会提示您如何构建自己的正则表达式