我的密码强度标准如下:
(!@#$&*)
(0-9)
有人可以给我同样的正则表达式吗?密码必须满足所有条件。
您可以使用积极的前瞻性断言进行这些检查:
^(?=.*[A-Z].*[A-Z])(?=.*[!@#$&*])(?=.*[0-9].*[0-9])(?=.*[a-z].*[a-z].*[a-z]).{8}$
红色链接
解释:
^ Start anchor (?=.*[A-Z].*[A-Z]) Ensure string has two uppercase letters. (?=.*[!@#$&*]) Ensure string has one special case letter. (?=.*[0-9].*[0-9]) Ensure string has two digits. (?=.*[a-z].*[a-z].*[a-z]) Ensure string has three lowercase letters. .{8} Ensure string is of length 8. $ End anchor.