语法?i:x使字符串搜索不区分大小写。例如
public class RegCaseSense {
public static void main(String[] args) {
String stringSearch = "嗨,我们在java课上。";
//这是行不通的,因为模式是大写
System.out.println("Try this 1: " + stringSearch.matches(".*CLASS.*"));
//神奇的(?i:X)语法使此搜索不区分大小写,因此返回true-
System.out.println("Try this 2: " + stringSearch.matches("(?i:.*CLASS.*)"));
}
}