你好,我正在编写一个java程序,以从包含php源代码的字符串中删除所有注释,任何人都可以给我php注释的正则表达式吗?请
看看这个链接:http://ostermiller.org/findcomment.html http://ostermiller.org/findcomment.html
他得出了这个解决方案(对于/* ... */
评论):
sourcecode.replaceAll("/\\*(?:.|[\\n\\r])*?\\*/","");
For // ...
and # ...
评论你应该能够做类似的事情
sourcecode.replaceAll("(//|#).*?[\\n\\r]");
但请注意以下类型的情况:
someString = "An example comment: /* example */";
someString = "An example comment: // example";
someString = "An example comment: # example";
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)