-
Bug
-
Resolution: Duplicate
-
P3
-
None
-
5.0
-
x86
-
windows_xp
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.
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.
- duplicates
-
JDK-6486934 RegEx case_insensitive match is broken
-
- Closed
-