密码政策:
每个密码至少应包含以下3个:
Numbers
a-z
A-Z
special characters !@#$%^&*()_+
例如,此列表:
12345678
adfghj
AASDFGHJ
!@#$%^&
1234as
1234ASDF
1345!#$%
asdfg!@#$
ASDFGB!#$$
SSRasd
Goodone123
G00done!@#
1@a
Aa1
应该是这样的:
Goodone123
G00done!@#
1@a
Aa1
感谢您的帮助:)
答案 0 :(得分:1)
让我们看看正则表达式可以匹配你的密码:
^ # 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
请参阅regex demo
要反转它,只需将:
替换为{!
,我们只需要将上面的非捕获交替组转换为否定前瞻 1}}:
^ # Start of line
(?! # A negative lookahead
请参阅online demo
要在Notepad ++中使用此功能,检查 Match case
选项,并在模式末尾添加\R*
还删除删除的行后删除换行符。在NPP中使用的一行:
^(?!(?=.*\d)(?=.*[a-z])(?=.*[A-Z])|(?=.*\d)(?=.*[a-z])(?=.*[!@#$%^&*()_+])|(?=.*\d)(?=.*[A-Z])(?=.*[!@#$%^&*()_+])|(?=.*[a-z])(?=.*[A-Z])(?=.*[!@#$%^&*()_+])|(?=.*[a-z])(?=.*[A-Z])(?=.*[!@#$%^&*()_+])).*$\R*
答案 1 :(得分:-1)
请参阅下面的npp正则表达式。 注意:确保选中Match Case
和Wrap Around
并选择了Regular expression
^[^\d\l]+$|^[^\d\u]+$|^[^\d\!\@\#\$\%\^\&\*\(\)\_\+]+$|^[^\l\u]+$|^[^\l\!\@\#\$\%\^\&\*\(\)\_\+]+$|^[^\u\!\@\#\$\%\^\&\*\(\)\_\+]+$
正则表达式匹配两个缺少密码标准的所有可能组合:
<强>更新强> Notepad ++参考How to use regular expressions in Notepad++