English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

예제를 포함한 Java의 UNICODE_CASE 필드를 패턴화

유니코드 대소문자 변환 지원을 활성화합니다.

CASE_INSENSITIVE 표시와 함께 compile() 메서드의 표시 값으로 사용할 때, 또한 유니코드 문자를 검색하는 정규 표현식을 사용할 때 두 가지 경우의 유니코드 문자가 모두 일치합니다.

예제

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);
         }
      }
   }
}

출력 결과

Þ is a match for Þ
þ is a match for Þ
î is not a match for Þ
Î is not a match for Þ