Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6487160

Pattern.UNICODE_CASE makes character class ranges case insensitive

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 5.0
    • core-libs

      FULL PRODUCT VERSION :
      java version "1.5.0_09"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_09-b01)
      Java HotSpot(TM) Client VM (build 1.5.0_09-b01, mixed mode, sharing)

      A DESCRIPTION OF THE PROBLEM :
      Enabling the Pattern.UNICODE_CASE makes character class ranges case insensitive.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Compile and run the source code provided in "Source code for an executable test case"

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Both the first and the second patterns should return identical results, which is that all the lower case letters of the string dogFace should be removed and the uppercase F remain in the result.
      ACTUAL -
      The first pattern returns incorrect results in that the upper case F is removed. The second returns F.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.util.regex.*;

      public class regextest
      {
      public static void main(String args[])
      {
      Pattern pattern = Pattern.compile("[a-z]", Pattern.UNICODE_CASE);
      System.err.println(pattern.matcher("dogFace").replaceAll(""));

      pattern = Pattern.compile("[abcdefghijklmnopqrstuvwxyz]", Pattern.UNICODE_CASE);
      System.err.println(pattern.matcher("dogFace").replaceAll(""));
      }
      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Don't use ranges in combination with UNICODE_CASE.

            sherman Xueming Shen
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: