我观察到以下行为在Python 2.7.5:Python re:为什么[,-_]匹配“=”?
>>> import re
>>> re.match(r'[,-_]', '=') # This matches
<_sre.SRE_Match object at 0x7f24d4981308>
>>> re.match(r'[-,_]', '=') # This doesn't match
>>> re.match(r'[-_,]', '=') # Nor does this
有人能解释我所看到的吗?我似乎无法找到任何关于,-_
在python正则表达式(或原始字符串)中的特殊用法。
[preg \ _match用户名验证正则表达式允许>和<尽管这些字符未被列入白名单]的可能重复(http://stackoverflow.com/questions/9996951/preg-match-username-validation-regex-allows-and -despite-those-characters-not) – Xufox