本文介绍了用于密码强度验证的RegEx问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在为我们的密码要求寻找一个正则表达式.密码:
I'm looking for a single regular expression for our password requirements. Passwords:
- 必须至少包含8个字符
- 不能包含空格
- 同时包含小写字母和大写字母
- 至少包含一个数字
- 至少包含一个特殊字符(即非
0-9,a-z,A-Z
的任何字符)
- Must be at least 8 characters
- Cannot contain spaces
- Contain both lowercase and UPPERCASE characters
- Contain at least one numeric digit
- Contain at least one special character (i.e. any character not
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.
这篇关于用于密码强度验证的RegEx问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!