English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Only when two character specifications are equal will the CANON_EQ field of the Pattern class match the two characters. When this value is used ascompile()}
When the flag value of the method is, two characters will be matched, and only when their complete canonical decomposition is equal will they match.
Canonical decomposition is one of the Unicode text normalization forms
import java.util.regex.Matcher; import java.util.regex.Pattern; public class CANON_EQ_Example { public static void main( String args[] ) { String regex = "b\u0307"; //Compile the regular expression Pattern pattern = Pattern.compile(regex, Pattern.CANON_EQ); //Retrieve the matcher object Matcher matcher = pattern.matcher("\u1E03); if(matcher.matches()) { System.out.println("Match found"); } else { System.out.println("Match not found"); } } }
Output Result
Match found
import java.util.regex.Matcher; import java.util.regex.Pattern; public class CANON_EQ_Example { public static void main( String args[] ) { String regex = "a\u030A"; //Compile the regular expression Pattern pattern = Pattern.compile(regex, Pattern.CANON_EQ); //Retrieve the matcher object String [] input = {"\u00E5", "a\u0311", "a\u0325", "a\u030A", "a\u1E03", "a\uFB03"}; for (String ele : input) { 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 Result
å is a match for a? a? is not a match for a? a? is not a match for a? a? is a match for a? a? is not a match for a? a? is not a match for a?