【发布时间】:2016-09-13 03:40:09
【问题描述】:
我有这个字符串:
The quick red fox jumped over the lazy brown dog lazy
我写了这个正则表达式,它给了我这个:
s = The quick red fox jumped over the lazy brown dog lazy
re.findall(r'[\s\w\S]*?(?=lazy)', ss)
这给了我以下输出:
['The quick red fox jumped over the ', '', 'azy brown dog ', '']
但我试图得到这样的输出:
['The quick red fox jumped over the ']
这意味着正则表达式应该给我一切,直到它遇到第一个 lazy 而不是最后一个,我只想使用 findall。
【问题讨论】: