正则表达式 – 密码的正则表达式(至少2位数字,一个特殊字符和最小长度8)

我一直在搜索正则表达式,它接受至少两位数字,一个特殊字符和最小密码长度为8.到目前为止,我已经完成了以下操作:[0-9a-zA-Z!@#$%0-9] [!@#$%0-9] [0-9a-zA-Z!@#$%0-9] *
这样的事情应该做的伎俩.
^(?=(.*\d){2})(?=.*[a-zA-Z])(?=.*[!@#$%])[0-9a-zA-Z!@#$%]{8,}

(?=(.*\d){2}) - uses lookahead (?=) and says the password must contain at least 2 digits

(?=.*[a-zA-Z]) - uses lookahead and says the password must contain an alpha

(?=.*[!@#$%]) - uses lookahead and says the password must contain 1 or more special characters which are defined

[0-9a-zA-Z!@#$%] - dictates the allowed characters

{8,} - says the password must be at least 8 characters long

它可能需要一点调整,例如指定您需要哪些特殊字符,但它应该做的伎俩.

相关文章

正则替换html代码中img标签的src值在开发富文本信息在移动端...
正则表达式
AWK是一种处理文本文件的语言,是一个强大的文件分析工具。它...
正则表达式是特殊的字符序列,利用事先定义好的特定字符以及...
Python界一名小学生,热心分享编程学习。
收集整理每周优质开发者内容,包括、、等方面。每周五定期发...