【发布时间】:2017-10-04 07:57:03
【问题描述】:
我在 python 2.7.5 中观察到以下行为:
>>> 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 正则表达式(或原始字符串)中的特殊之处。
【问题讨论】:
标签: python regex python-2.7