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("<!--.*?-->", "");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With