প্যাটার্ন ক্লাসের CANON_EQ ক্ষেত্রটি দুটি অক্ষরের সাথে মেলে শুধুমাত্র যদি তারা ক্যানোনিকভাবে সমান হয়। আপনি যখন কম্পাইল() পদ্ধতিতে ফ্ল্যাগ মান হিসাবে এটি ব্যবহার করেন, তখন দুটি অক্ষর মিলিত হবে যদি এবং শুধুমাত্র যদি তাদের সম্পূর্ণ ক্যানোনিকাল পচন সমান হয়।
যেখানে ক্যানোনিকাল পচন ইউনিকোড পাঠ্য স্বাভাবিকীকরণ ফর্মগুলির মধ্যে একটি
উদাহরণ 1
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";
//Compiling the regular expression
Pattern pattern = Pattern.compile(regex, Pattern.CANON_EQ);
//Retrieving the matcher object
Matcher matcher = pattern.matcher("\u1E03");
if(matcher.matches()) {
System.out.println("Match found");
} else {
System.out.println("Match not found");
}
}
} আউটপুট
Match found
উদাহরণ 2
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";
//Compiling the regular expression
Pattern pattern = Pattern.compile(regex, Pattern.CANON_EQ);
//Retrieving 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);
}
}
}
} আউটপুট
å 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?