A字符串包含B字符串
String source = "china";
String target = "INA";
//contains true 包含
boolean containsFlag = source.contains(target);
//indexOf 1 包含 返回子字符串在当前字符串的位置,如果当前字符串不包含子字符串就返回-1
int indexNum = source.indexOf(target);
//java.util.regex
boolean patternFlag = Pattern.compile(Pattern.quote(target), Pattern.CASE_INSENSITIVE).matcher(source).find();
System.out.println("containsFlag==" + containsFlag);//containsFlag==false
System.out.println("indexNum==" + indexNum);// indexNum==-1
System.out.println("patternFlag==" + patternFlag);// patternFlag==true
标签:target,包含,patternFlag,containsFlag,source,字符串,indexNum
From: https://www.cnblogs.com/fightmonster/p/17030712.html