需求:密码只能是8-16位的字母、数字以及英文标点符号(~!@#$%^&*()_+?-=.)且同时包含大小写字母
import re
a = "9224214124_4aW"
pattern = "^((?=.*[A-Z])(?=.*[a-z]))[~\!@#\$%\^&\*\(\)\_\+\?\-\=\.0-9A-Za-z]{8,16}$"
res = re.match(pattern, a)
print(res)
需求:密码只能是8-16位的字母、数字以及英文标点符号(~!@#$%^&*()_+?-=.)且同时包含大小写字母
import re
a = "9224214124_4aW"
pattern = "^((?=.*[A-Z])(?=.*[a-z]))[~\!@#\$%\^&\*\(\)\_\+\?\-\=\.0-9A-Za-z]{8,16}$"
res = re.match(pattern, a)
print(res)