开发者

Regex to remove comments in XML file in Eclipse java

开发者 https://www.devze.com 2023-03-22 23:55 出处:网络
Can anyone tell me how to write a regular expression to match the comments in XML file, for example,

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

精彩评论

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