密码复杂性的正则表达式 [英] Regular expression for password complexity
本文介绍了密码复杂性的正则表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试通过客户端 (JavaScript) 和服务器端 (ASP.NET C#) 上的正则表达式来实施密码复杂性.
I am trying to implement the enforcement of password complexity through regular expressions on both client (JavaScript) and server side (ASP.NET C#).
规则如下:
- 必须是 8-40 个字符
- 必须至少包含一位数字
- 必须至少包含一个小写字母
- 必须至少包含一个大写字母
- 必须至少包含一个特殊字符
您能帮忙构建验证上述内容所需的正则表达式吗?
Can you please help construct the regular expression needed to validate the above?
推荐答案
在这里试试这个正则表达式:
try this regex here:
((?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%]).{8,40})
( # Start of group
(?=.*\d) # must contains one digit from 0-9
(?=.*[a-z]) # must contains one lowercase characters
(?=.*[A-Z]) # must contains one uppercase characters
(?=.*[@#$%]) # must contains one special symbols in the list "@#$%"
. # match anything with previous condition checking
{8,40} # length at least 8 characters and maximum of 40
)
这篇关于密码复杂性的正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文