如果匹配在python中太短,则排除与regex的第一个匹配

时间:2019-02-06 10:03:50

标签: python regex

在Python中,我正在搜索两个词之间的字符串,即IntroductionTheory Development

string = "Introduction: What is game Game Theory ? Theory Development. Introduction: What is game Game Theory ? Probably real content is here. Theory Development."

在这种情况下,我想获得第二个。总的来说,在所有比赛中,我想得到最长的一场。我该怎么办?

我目前正在这样做:

import re
regex = 'Introduction(.+?)Theory Development'
match = re.search(regex, string, flags=re.IGNORECASE)
rawText = match.group(1)

0 个答案:

没有答案