我正在尝试通过客户端(JavaScript)和服务器端(ASP.NET C#)上的正则表达式实现密码复杂性的实施。
规则如下:
请帮助构建验证上述所需的正则表达式吗?
答案 0 :(得分:5)
在这里试试这个正则表达式:
((?=.*\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
)