java正则表达式替换(保留源文件中注释)

来源:互联网 发布:mac ps插件安装 编辑:程序博客网 时间:2024/05/16 09:02

void doSomething(File file){
File[] files=file.listFiles();
for(File f:files){
                        if(f.isDirectory() )
       
            doSomething(f);
  
            else
        //处理文件,提取注释
}
}

 

 


public static String regex(String source){
 
 Pattern pattern=Pattern.compile("///*.*?//*/", Pattern.DOTALL | Pattern.MULTILINE);
  
        StringBuilder sb=new StringBuilder();
 
 Matcher matcher=pattern.matcher(source);
 
 while(matcher.find()){
   
        sb.append(matcher.group());
  
 sb.append('/n');
  
       }
 
 return sb.toString(则表达式)

 

 

 

 

 

 

其实myeclipse只是项目的多文件替换!!!!,这几天才知道。


去掉/* */(eclipse)     //*(.|[/r/n])*?/*/
去掉//(eclipse)         //.*$
去掉import(eclipse)     import.*$
去掉空行(eclipse)        ^/s*/n
去掉空行(ue)    %[ ^t]++^p

原创粉丝点击