-
Bug
-
Resolution: Fixed
-
P3
-
1.4.1
-
rc
-
x86
-
windows_98, windows_2000
-
Verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2056229 | 1.4.2 | Michael Mccloskey | P3 | Resolved | Fixed | b02 |
Name: nt126004 Date: 07/08/2002
FULL PRODUCT VERSION :
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1-beta-b14)
Java HotSpot(TM) Client VM (build 1.4.1-beta-b14, mixed mode)
FULL OPERATING SYSTEM VERSION :
Microsoft Windows 2000 [Version 5.00.2195]
ADDITIONAL OPERATING SYSTEMS :
N/A
EXTRA RELEVANT SYSTEM CONFIGURATION :
Nothing special, pure java.util.regex issue.
Problem occurs with both client and server VMs.
A DESCRIPTION OF THE PROBLEM :
Using Pattern and Matcher in java.util.regex to replace CR
(regex '$') with some other String, Java 1.4.0 works fine
but 1.4.1 beta matches on almost every character, rather
than just end-of-line chars.
REGRESSION. Last worked in version 1.4
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Run the example code with Java 1.4.0_01 and Java 1.4.1
beta
2. Compare actual and expected output.
EXPECTED VERSUS ACTUAL BEHAVIOR :
With 1.4.0_01 I get (good):
was: first bit
second bit
is : first bitCRsecond bitCR
With 1.4.1 beta I get (bad):
was: first bit
second bit
is : CRfCRiCRrCRsCRtCR CRbCRiCRtCR
CRsCReCRcCRoCRnCRdCR CRbitCR
ERROR MESSAGES/STACK TRACES THAT OCCUR :
No exceptions or errors, just incorrect output.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.util.regex.*;
public class DollarTest {
public static void main(String[] args) {
Pattern findCR = Pattern.compile("$", Pattern.MULTILINE);
String testString = "first bit\nsecond bit";
Matcher matcher = findCR.matcher(testString);
String output = matcher.replaceAll("CR"); // I do mean the String "CR"
System.out.println("was: "+testString);
System.out.println("is : "+output);
}
}
---------- END SOURCE ----------
CUSTOMER WORKAROUND :
Not worked out one yet, will stick to Java 1.4.0_01 for the
moment.
Release Regression From : 1.4.0_01
The above release value was the last known release where this
bug was known to work. Since then there has been a regression.
(Review ID: 158892)
======================================================================
- backported by
-
JDK-2056229 REGRESSION: Regex: replacing '$' i.e. EOL fails
- Resolved
- duplicates
-
JDK-4711986 REGRESSION: java.util.regex.Pattern Multiline $: matches everywhere
- Closed