Python 如何在mediawiki框中匹配包含换行符的字符串?

Python 如何在mediawiki框中匹配包含换行符的字符串?,python,regex,Python,Regex,我使用python,我有如下字符串: anything include {{infobox notperson anything include new line}} anything {{infobox person anything many new lines and any charachter }} anything include {{infobox notperson anything include new line}} 我想使用regexp,从{infobox person到

我使用python,我有如下字符串:

anything include {{infobox notperson anything include new line}}
anything
{{infobox person anything
many new lines and any charachter
}}
anything include {{infobox notperson anything include new line}}

我想使用regexp,从{infobox person到第一个{infobox person字符,即infobox区域的末尾,获取整个infobox person区域。我应该使用什么regexp?

您需要使用
re.DOTALL
标志,以便
匹配换行符:

这是您要查找的regexp:

re.compile("\{\{infobox person[^\}]*\}\}",re.DOTALL)

edit:正如Jerry指出的那样,不需要使用
DOTALL
,因为
[^\}]
已经匹配了换行符。

它可以工作,但是有没有非python的、只有regexp的方法?