假设有一个wikiText字符串,例如:
{{ValueDescription
|key=highway
|value=secondary
|image=Image:Meyenburg-L134.jpg
|description=A highway linking large towns.
|onNode=no
|onWay=yes
|onArea=no
|combination=
* {{Tag|name}}
* {{Tag|ref}}
|implies=
* {{Tag|motorcar||yes}}
}}
我希望能够在Java/Groovy中解析模板
ValueDescription
和Tag
。我尝试使用正则表达式/\{\{\s*Tag(.+)\}\}/
,它很好用(它返回|name
|ref
和|motorcar||yes
),但是/\{\{\s*ValueDescription(.+)\}\}/
不起作用(它应该返回上面的所有文本)。期望的输出是:
有没有办法在正则表达式中跳过嵌套的模板?
理想情况下,我更愿意使用简单的wikiText 2 xml工具,但我找不到类似的东西。
谢谢! Mulone