我以前从未使用过正则表达式。我正在寻找一个正则表达式命令,它可以帮助我为“:”之后的行添加书签,这些行包含:
- 至少 1 个大写字母
- 至少 1 个小写字母
- 至少 1 个数字或特殊字符(如
!,#,$,@
)。
例子:
x361:HDKS1a!
X73:HDKS1
X72:SSa$
X31:aa1$
x21:Sa123
已加书签的行:
x361:HDKS1a!
X72:SSa$
x21:Sa123
答案1
- Ctrl+M
- 找什么:
^.+:(?=.*[A-Z])(?=.*[a-z])(?=.*[\d!#$@]).+$
- 查看 书签行
- 查看 相符
- 取消选中
. matches newline
- Mark all
解释:
^ # beginning of line
.+ # 1 or more any character
: # a colon
(?=.*[A-Z]) # positive lookahead, make sure we have an uppercase letter
(?=.*[a-z]) # positive lookahead, make sure we have an lowercase letter
(?=.*[\d!#$@]) # positive lookahead, make sure we have a digit or a special char
.+ # 1 or more any character
$ # end of line
截屏: