[英]Remove comments from text file in Java
Is there any easy way to remove the comments from the text file in Java. 有没有简单的方法从Java中删除文本文件中的注释。
now:
:- /* #pos=1,513 */ author(A, UniqueVar1)
after:
author(A, UniqueVar1)
I used BufferedReader and readline to read and split the lines. 我使用BufferedReader和readline来读取和分割行。
试试这个:
line.replaceAll("(?:/\\*(?:[^*]|(?:\\*+[^*/]))*\\*+/)|(?://.*)|(?::-)","");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.