เปิดใช้งาน Unicode-aware case folding
เมื่อคุณใช้เป็น flag value ในเมธอด compile() พร้อมกับ flag CASE_INSENSITIVE และหากคุณค้นหาตัวอักษร Unicode โดยใช้ regular expressions ตัวอักษร Unicode ของทั้งสอง case จะถูกจับคู่
ตัวอย่าง
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class UNICODE_CASE_Example {
public static void main(String args[]) {
String regex = "\u00de";
// คอมไพล์ regular expression
Pattern pattern = Pattern.compile(regex, Pattern.UNICODE_CASE | Pattern.CASE_INSENSITIVE);
// ดึง Matcher object
String str[] = {"\u00de", "\u00fe", "\u00ee", "\u00ce"};
for (String ele : str) {
Matcher matcher = pattern.matcher(ele);
if (matcher.matches()) {
System.out.println(ele + " is a match for " + regex);
} else {
System.out.println(ele + " is not a match for " + regex);
}
}
}
}
Output
Þ is a match for Þ þ is a match for Þ î is not a match for Þ Î is not a match for Þ