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("<!--.*?-->", "");
精彩评论