正则表达式以获取默认的ASP.NET Core身份密码 [英] Regex for default ASP.NET Core Identity Password
问题描述
注意:我相信这个问题不是这个问题的重复部分.我的问题是处理asp.net核心身份用于密码验证的默认验证规则以及如何进行正则表达式,而链接的问题在讨论时,通常涉及验证密码的行为(这不能解决我的问题)
Note: This question, I believe, is not the duplicate of this question. My question is dealing with the default validation rules asp.net core identity has for password validation and how it's regex can be made, while the linked question is discussing, in general about act of validating password (which doesn't solve my problem)
ASP.NET Core启用默认的以下密码验证
The ASP.NET Core enables default following password validation
- 最少8个字符
- 至少应有一个数字
- 应该至少有一个大写字母
- 应该至少有一个小写字母
- 至少应有一个特殊字符(允许使用哪些特殊字符?)
牢记这些条件,我尝试制作以下正则表达式,但不起作用.
Keeping these conditions in mind I tried making the following regex but it is not working.
^((?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])|(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[^a-zA-Z0-9])|(?=.*?[A-Z])(?=.*?[0-9])(?=.*?[^a-zA-Z0-9])|(?=.*?[a-z])(?=.*?[0-9])(?=.*?[^a-zA-Z0-9])).{8,}$
即使来自点2,3,4,5的三个条件之一匹配,此正则表达式也接受字符串.但我希望所有条件都应满足.
This regex is accepting the strings even when either of three conditions from points 2,3,4,5 matches. But I want that all conditions should satisfy.
我在做什么错了?
推荐答案
因此,请使用
^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[#$^+=!*()@%&]).{8,}$
-
^
:第一行 - (?=.* [a-z]):应该至少包含一个小写字母
- (?=.* [A-Z]):应该至少有一个大写字母
- (?=.* \ d):应该至少有一个数字
- (?=.* [#$ ^ + =!*()@%&]):应该至少有一个特殊字符
- .{8,}:至少8个字符
- $:结束行
^
: first line- (?=.*[a-z]) : Should have at least one lower case
- (?=.*[A-Z]) : Should have at least one upper case
- (?=.*\d) : Should have at least one number
- (?=.*[#$^+=!*()@%&] ) : Should have at least one special character
- .{8,} : Minimum 8 characters
- $ : end line
有关更多信息:此
这篇关于正则表达式以获取默认的ASP.NET Core身份密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!