让我们看看什么正则表达式可以匹配您的密码:
^ # Start of line
(?: # Start of the alternation group
(?=.*\d)(?=.*[a-z])(?=.*[A-Z]) # Conditions 1, 2, 3
|
(?=.*\d)(?=.*[a-z])(?=.*[!@#$%^&*()_+]) # Conditions 1, 2, 4
|
(?=.*\d)(?=.*[A-Z])(?=.*[!@#$%^&*()_+]) # Conditions 1, 3, 4
|
(?=.*[a-z])(?=.*[A-Z])(?=.*[!@#$%^&*()_+]) # Conditions 2, 3, 4
|
(?=.*[a-z])(?=.*[A-Z])(?=.*[!@#$%^&*()_+]) # Conditions 1, 3, 4
)
.* # The line itself is matched
$ # Up to the end of line
查看正则表达式演示
要反转它,我们只需将上面的非捕获交替组转换为负前瞻,只需将 替换:
为!
:
^ # Start of line
(?! # A negative lookahead
查看在线演示
要在 Notepad++ 中使用此功能,请选中Match case
option,并在模式末尾添加\R*
以同时删除已删除行之后的换行符。用于 NPP 的一条线路:
^(?!(?=.*\d)(?=.*[a-z])(?=.*[A-Z])|(?=.*\d)(?=.*[a-z])(?=.*[!@#$%^&*()_+])|(?=.*\d)(?=.*[A-Z])(?=.*[!@#$%^&*()_+])|(?=.*[a-z])(?=.*[A-Z])(?=.*[!@#$%^&*()_+])|(?=.*[a-z])(?=.*[A-Z])(?=.*[!@#$%^&*()_+])).*$\R*
