
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Pattern UNICODE_CASE field in Java with examples
Enables Unicode-aware case folding.
When you use this as flag value to the compile() method along with the CASE_INSENSITIVE flag and if you search for Unicode characters using regular expressions Unicode characters of both cases will be matched.
Example
import java.util.regex.Matcher; import java.util.regex.Pattern; public class UNICODE_CASE_Example { public static void main( String args[] ) { String regex = "\u00de"; //Compiling the regular expression Pattern pattern = Pattern.compile(regex, Pattern.UNICODE_CASE|Pattern.CASE_INSENSITIVE); //Retrieving the 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 Þ
- Related Questions & Answers
- Pattern CANON_EQ field in Java with examples
- Pattern CASE_INSENSITIVE field in Java with examples
- Pattern COMMENTS field in Java with examples
- Pattern DOTALL field in Java with examples
- Pattern LITERAL field in Java with examples
- Pattern MULTILINE field in Java with examples
- Pattern UNIX_LINES field in Java with examples
- Pattern UNICODE_CHARACTER_CLASS field in Java with examples
- Pattern pattern() method in Java with examples
- Pattern compile() method in Java with Examples
- Pattern matcher() method in Java with examples
- Pattern quote() method in Java with examples
- Pattern matches() method in Java with examples
- Pattern split() method in Java with examples
- Pattern splitAsStream() method in Java with examples
Advertisements