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且包含first
if(word.matches("(?=.*check)(?=.*first)^.*$"))
matches.add(word);
}
System.out.println(Arrays.toString(matches.toArray()));