【发布时间】:2016-03-18 16:51:15
【问题描述】:
我有这段文字:
{{Infobox Item
|name = value
|prop2 = value
|prop3 = value
}}
它来自一个 mediawiki 模板。
我有以下正则表达式:
preg_match('/\{\{Infobox Item.+\\n\}\}\\n/s', $text, $ra);
我正在使用 PHP。
我想匹配从{{Infobox Item 到第一次出现的}},它总是会单独出现在一行上。上面的正则表达式将从{{Infobox Item 匹配到另一个{{ }} 样式块的末尾,这不是我想要的。我怎样才能做到这一点?
【问题讨论】:
-
参见How do you extract information from a Wikipedia infobox?,了解正则表达式对信息框的一般适用性。
标签: php regex mediawiki-templates