// llo不分大小写换成AA;
public class TestString3 {
public static void main(String[] args){
String s="hello lucy,Wecome to china!/heLLo lucy,Wecome to china!";
// 方法1、
String s1=s.replaceAll( "(L|l)(L|l)(O|o)", "AA");
System.out.println(s1);
// 方法2、
String s2="llo";
Pattern pattern=Pattern.compile(s2,Pattern.CASE_INSENSITIVE);
Matcher matcher=pattern.matcher(s);
String string=matcher.replaceAll("AA");
System.out.println(string);
// 方法3、此方法效率比较低
String r1 =s.replaceAll("(?i)"+"llo", "AA"); //大小写不敏感
System.out.println(r1);
}
}
// 答案 heAA lucy,Wecome to china!/heAA lucy,Wecome to china!