密码强度验证的正则表达式问题强度、密码、问题、正则表达式

2023-09-06 23:25:00 作者:画眉

我正在为我们的密码要求寻找一个单一的正则表达式.密码:

I'm looking for a single regular expression for our password requirements. Passwords:

必须至少为 8 个字符不能包含空格同时包含小写和大写字符至少包含一位数字至少包含一个特殊字符(即任何非0-9,a-z,A-Z的字符)

推荐答案

想法和大部分工作取自 http://www.zorched.net/2009/05/08/password-strength-validation-with-regular-expressions/

Idea and most of the work taken from http://www.zorched.net/2009/05/08/password-strength-validation-with-regular-expressions/

^S*(?=S{8,})(?=S*[a-z])(?=S*[A-Z])(?=S*[d])(?=S*[W])S*$

我使用了他帖子底部的基本答案,但用 S 替换了所有点以排除空格字符,并移动了一些断言.

I used the basic answer at the bottom of his post, but replaced all the dots with S to rule out space characters, and moved around some of the assertions.