String[] searchText = {"体育","足球","比赛","时间"}; 我如何搜索这些词是否在文件中可用
最佳答案
这应该可以工作(给定一些代表文档的 String )
Pattern p = Pattern.compile("(sports|football|play|time)");
Matcher m = p.matcher(s);
int start = 0;
while (m.find(start)) {
System.out.println("Match found: " + m.group(1) + " at position: " + m.start());
start = m.end();
}
关于java - 在java中搜索文件中的多个字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5694913/