开发者

Regex to remove comments in XML file in Eclipse java

Can anyone tell me how to write a regular expression to match the comments in XML file, for example,

<!-- Global JNDI resources
   Documentation at /docs/jndi-resources-howto.html
-->

I'm using Eclipse (java) and want开发者_开发问答 to remove those comments from XML file.


xmlFileContent.replaceAll( "(?s)<!--.*?-->", "" );


xmlFileContent.replaceAll("<!--[\s\S]*?-->", "");

[\s\S] works like '.', but will consume line endings as well.


xmlFileContent.replaceAll("<!--.*?-->", "");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜