代码:
#coding=utf-8
import re
s = 'abc111def abc222def abc345xyz abc678xyz'
reg = r'(?<=abc)((?!abc).)+(?=xyz)'
imgre = re.compile(reg)
re.search(imgre, s)
print ('re.search = ' + re.search(imgre, s).group())
print ('re.findall =', re.findall(imgre, s))
结果:
re.search = 345
re.findall = ['5', '8']
跪求解释findall为啥不是['345', '678']