我正在尝试验证至少一个大写字母,一个小写字母和一个数字。到目前为止,我有:
"orange" -match "(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).*"
False
好
"Orange22" -match "(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).*"
True
好
"orange22" -match "(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).*"
True
错误-没有大写字母,但仍然是一个匹配项。
正则表达式示例出了什么问题?
答案 0 :(得分:4)
Powershell正则表达式默认情况下不区分大小写。不用-match
,而要使用-cmatch
:
"orange22" -cmatch "(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).*"