0

需要帮助找出我需要删除 {{ 和 }} 之间所有数据的正则表达式吗?

下面是coupus:

{{for|the American actor|Russ Conway (actor)}}
{{Use dmy dates|date=November 2012}}
{{Infobox musical artist <!-- See Wikipedia:WikiProject_Musicians -->
| birth_name          = Trevor Herbert Stanford
| birth_date          = {{birth date|1925|09|2|df=y}}
| birth_place         = [[Bristol]], [[England]], UK
| death_date          = {{death date and age|2000|11|16|1925|09|02|df=y}}
| death_place         = [[Eastbourne]], [[Sussex]], England, UK
| origin              = 
}}

record|hits]].<ref name="British Hit Singles & Albums"/>

{{reflist}}

==External links==
*[http://www.russconway.co.uk/ Russ Conway]
*{{YouTube|TnIpQhDn4Zg|Russ Conway playing Side Saddle}}

{{Authority control|VIAF=41343596}}

<!-- Metadata: see [[Wikipedia:Persondata]] -->
{{Persondata
| NAME              =Conway, Russ
}}
{{DEFAULTSORT:Conway, Russ}}
[[Category:1925 births]]

下面是所有花括号连同其中的文本一起被删除的输出:

record|hits]].<ref name="British Hit Singles & Albums"/>
==External links==
*[http://www.russconway.co.uk/ Russ Conway]
*
<!-- Metadata: see [[Wikipedia:Persondata]] -->
[[Category:1925 births]]

PS - 我省略了输出中的空格,我会处理的。

4

2 回答 2

0
string.replaceAll("\\{\\{[\\s\\S]*?\\}\\}","");

将产生:




record|hits]].<ref name="British Hit Singles & Albums"/>



==外部链接==
*[http://www.russconway.co.uk/拉斯康威]
*



<!-- 元数据:参见 [[Wikipedia:Persondata]] -->


[[类别:1925年出生]]
于 2013-09-20T07:56:08.067 回答
0

这将照顾嵌套{{ }}

Matcher m=Pattern.compile("\\{[^{}]*\\}").matcher(input);
while(m.find())
{
    input=m.replaceAll("");
    m.reset(input);
}
于 2013-09-20T07:56:40.783 回答