本文主要是介绍【正则表达】同时包含2个甚至多个关键字 content.contains(keyword1)content.contains(keyword2),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
有三个字符串如何匹配同时包含两个关键字的字符串
str1 = "this is the first check run" str2 = "the first run" str3 = "the first time runing" 有两个关键字(“first ”、”check “) 正则表达式怎么写 然后匹配到str1
// regExp (?=.*我是谁)(?=.*C)^.*$
// java code
List<String> list = Arrays.asList(new String[]{"this is the first check run","the first run","the first time runing"
});List<String> matches = new ArrayList<String>();for(String word : list){//包含check且包含firstif(word.matches("(?=.*check)(?=.*first)^.*$"))matches.add(word);
}System.out.println(Arrays.toString(matches.toArray()));
这篇关于【正则表达】同时包含2个甚至多个关键字 content.contains(keyword1)content.contains(keyword2)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!