You are viewing a plain text version of this content. The canonical link for it is here.
Posted to regexp-dev@jakarta.apache.org by bu...@apache.org on 2001/10/16 00:52:01 UTC
DO NOT REPLY [Bug 4183] New: -
regexp match gets different results on different platforms
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=4183>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND
INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=4183
regexp match gets different results on different platforms
Summary: regexp match gets different results on different
platforms
Product: Regexp
Version: unspecified
Platform: All
OS/Version: All
Status: NEW
Severity: Normal
Priority: Other
Component: Other
AssignedTo: regexp-dev@jakarta.apache.org
ReportedBy: steven@void.org
The following code, which uses the regexp1.2 package, gets different results when running on windows NT and linux, both running the javasoft jdk 1.3. The problem seems to be with the handling of \n in multiline matches.
See the comment at the beginning of the class for some more detail.
--- BadRE.java ---
import org.apache.regexp.*;
// The following class defines a regular expression and attempts to
// match a text string with it. The regular expression is trying to
// match the literal "window.location.href=" at the beginning of a
// line, following any number of space characters.
//
// The results are different on Windows NT and Linux. On linux
// running sun jdk1.3, it matches. On Windows NT Workstation running
// sun jdk1.3, it doesn't match.
//
// If the \n is removed from the beginning of the input string then it
// matches on windows and linux.
// If bol (beginning-of-line) is changed from "^[ \t]*" to "^[ \t\n]*" then
// it matches on windows and linux.
// If bol is changed to "^\n[ \t]*" then it matches on windows and linux.
//
public class BadRE {
public static RE makeRE() throws RESyntaxException {
String bol = "^[ \t]*";
String regexp = bol + "window.location.href=";
RE matchRE = new RE(regexp, RE.MATCH_MULTILINE | RE.MATCH_CASEINDEPENDENT);
return matchRE;
}
public static void test() throws RESyntaxException {
String input = "\nwindow.location.href=";
RE re = makeRE();
if (re.match(input)) {
System.out.println("match: " + re.getParen(0));
}
else {
System.out.println("no match");
}
}
public static void main(String [] args) throws RESyntaxException {
test();
}
}