python正则表达看看周围

时间:2015-11-06 09:01:58

标签: python regex regex-lookarounds

有谁可以弄清楚为什么这两个结果完全不同:

导入重新

a = re.findall(r'\w+(?=,|\.)',"They were three: Felix, Victor, and Carlos.") ; print(a)
a = re.findall(r'\w+(?=(,|\.))',"They were three: Felix, Victor, and Carlos.") ; print(a)

第一次回归:[' Felix',' Victor',' Carlos']

第二次回复:[',',',','。']

谢谢, 阿斯卡尼奥

0 个答案:

没有答案