Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
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_CHARACTER_CLASS field in Java with examples
Enables the Unicode version of Predefined character classes and POSIX character classes.
Example
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class UNICODE_CHARACTER_CLASS_Example {
public static void main( String args[] ) {
String regex = "\u00de";
//Compiling the regular expression
Pattern pattern = Pattern.compile(regex, Pattern.UNICODE_CHARACTER_CLASS);
//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 not a match for ? ? is not a match for ? ? is not a match for ?
Advertisements