jakarta-regexp-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 22966] New: - off by two error in RE.subst
Date Sun, 07 Sep 2003 14:40:34 GMT
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=22966>.
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=22966

off by two error in RE.subst

           Summary: off by two error in RE.subst
           Product: Regexp
           Version: unspecified
          Platform: Macintosh
        OS/Version: MacOS X
            Status: NEW
          Severity: Critical
          Priority: Other
         Component: Other
        AssignedTo: regexp-dev@jakarta.apache.org
        ReportedBy: jakob@rfc.se


the following trivial test program triggers a bug in RE.subst:

import org.apache.regexp.*;
import java.io.*; 
import java.text.*; 
import java.util.*; 
public class test
{ 
    public static void main(String[] args)
    {
	RE regexp = new RE("http://(.*)/(.*)");
	String test = "http://www.apache.org/test";
	System.out.println(regexp.subst(test, "host: $1",
					RE.REPLACE_BACKREFERENCES));
	System.out.println(regexp.subst(test, "dir: $2",
					RE.REPLACE_BACKREFERENCES));
    }
}

outputs:

st: www.apache.org
r: test

instead of:

host: www.apache.org
dir: test

Mime
View raw message