[英]javascript regular expression to recognize all special characters
I am writing a regular expression for a stronger password which needs atleast one small case letter, upper case letter, one number, one special character and has length=8 or above.我正在为更强的密码编写正则表达式,该密码至少需要一个小写字母、大写字母、一个数字、一个特殊字符,并且长度为 8 或以上。
I have the below one regular expression.我有以下一个正则表达式。
/(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*\W).{8,}/
The problem with this one is it is not considering underscore('_') character as a special character.这个问题是它没有将下划线('_')字符视为特殊字符。 How can I include this in the list of special characters?
如何将其包含在特殊字符列表中?
Thanks in advance.提前致谢。
_
is a word-character and thus not included in the \\W
( not word) class. _
是一个单词字符,因此不包含在\\W
(非单词)类中。 Put the \\W
inside []
and add the _
like将
\\W
放入[]
并添加_
类的
/(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[\W_]).{8,}/
That should do it那应该这样做
Regards问候
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.