正则表达式 – 密码的正则表达式(至少2位数字,一个特殊字符和最
发布时间:2020-12-13 22:54:59 所属栏目:百科 来源:网络整理
导读:我一直在搜索正则表达式,它接受至少两位数字,一个特殊字符和最小密码长度为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.到目前为止,我已经完成了以下操作:[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 它可能需要一点调整,例如指定您需要哪些特殊字符,但它应该做的伎俩. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |