赞
踩
https://blog.csdn.net/weixin_43732798/article/details/100067094
import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; import java.util.regex.Matcher; import java.util.regex.Pattern; /* ddd eee */ public class Main3 { public static void main(String[] args) throws IOException { String filePath = "./src/Main3.java"; //hehe String jsContent = new String(Files.readAllBytes(Paths.get(filePath))); // System.out.println(jsContent); Pattern p=Pattern.compile("/\\*.*?\\*/",Pattern.MULTILINE|Pattern.DOTALL); Matcher m=p.matcher(jsContent); while(m.find()){ System.out.println(m.group()+" 位置:["+m.start()+","+m.end()+"]"); } } }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。