首页 > 无法用正则表达式匹配含有"\"的字符串?

无法用正则表达式匹配含有"\"的字符串?

判断字符串中是否含有“\xe2”或"\x325"

pattern = re.compile(r'\\x([a-z]+|\d+)+')

p = pattern.search('WA\xe23')

print p

结果:none,说明没有匹配成功

请教。


'WA\xe23' 这个字符串可不包含'\','WA\\xe23'才包含~~

>>> print '\x61'
a
>>> print '\\x61'
\x61
【热门文章】
【热门文章】