English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Activer les classes de caractères prédéfinies Unicode et POSIX de la version Unicode.
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\"; //Compilation de l'expression régulière Pattern pattern = Pattern.compile(regex, Pattern.UNICODE_CHARACTER_CLASS); //Recherche de l'objet du matcheur String str[] = {\"\u00de\", \"\u00fe\", \"\u00ee\", \"\u00ce\"}; for (String ele : str) { Matcher matcher = pattern.matcher(ele); if(matcher.matches()) { System.out.println(ele+" est un correspondant pour "+regex); } else { System.out.println(ele+" est pas un correspondant pour "+regex); } } } }
Résultat de la sortie
Þ est un correspondant pour Þ þ est un correspondant pour Þ î est pas un correspondant pour Þ Î est pas un correspondant pour Þ