我一直在搜索正则表达式,它接受至少两位数字,一个特殊字符和最小密码长度为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
它可能需要一点调整,例如指定您需要哪些特殊字符,但它应该做的伎俩.