这个问题在这里已经有了答案:
Regular expression to check if password is "8 characters including 1 uppercase letter, 1 special character, alphanumeric characters"
(14 个回答)
Password regex for specific requirements
(1 个回答)
5年前关闭。
我需要 1 个大写 1 个特殊字符和 1 个小写的正则表达式
注意需要允许所有特殊字符,并且长度应在 8 个字符以上。
我试过 /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[$@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$/
但这限制了一些特殊字符。
最佳答案
尝试使用这个正则表达式:
^(?=.{8,})(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%^&+*!=]).*$
REGEX DEMO
说明:
(/^
(?=.{8,}) //should be 8 characters or more
(?=.*[a-z]) //should contain at least one lower case
(?=.*[A-Z]) //should contain at least one upper case
(?=.*[@#$%^&+*!=]) //should contain at least 1 special characters
.*$/)
关于1 个大写 1 个特殊字符和 1 个小写的正则表达式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33670870/