任何人都可以告诉我如何编写正则表达式来匹配XML文件中的注释,例如,
<!-- Global JNDI resources
Documentation at /docs/jndi-resources-howto.html
-->
Run Code Online (Sandbox Code Playgroud)
我正在使用Eclipse(java)并希望从XML文件中删除这些注释.
nob*_*ody 18
xmlFileContent.replaceAll( "(?s)<!--.*?-->", "" );
Run Code Online (Sandbox Code Playgroud)
小智 9
xmlFileContent.replaceAll("<!--[\s\S]*?-->", "");
Run Code Online (Sandbox Code Playgroud)
[\ s\S]的工作方式类似于'.',但也会消耗行结尾.