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 22928] New: - subst() with REPLACE_BACKREFERENCES cuts first 2 characters
Date Thu, 04 Sep 2003 09:25:51 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=22928>.
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=22928

subst() with REPLACE_BACKREFERENCES cuts first 2 characters

           Summary: subst() with REPLACE_BACKREFERENCES cuts first 2
                    characters
           Product: Regexp
           Version: unspecified
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Other
        AssignedTo: regexp-dev@jakarta.apache.org
        ReportedBy: sascha.spiekermann@gmx.net


Just tried the new subst()-Method with the pattern "http://[\.\w\-\?/~_@&=%]+", 
input "visit us: http://www.apache.org!" and substitution "1234<a 
href="$0">$0</a>". The call of subst
(input,substitute,RE.REPLACE_BACKREFERENCES) produces "visit us: 34<a 
href="http://www.apache.org">http://www.apache.org</a>!", the first two numbers 
are cut away.
Another Try: "variable=value" against "(.*?)=(.*)" and "$1_test=$2" produces 
following:

String index out of range: -2
java.lang.StringIndexOutOfBoundsException: String index out of range: -2
	at java.lang.String.substring(String.java:1480)
	at org.apache.regexp.RE.subst(Unknown Source)
.....

Same call, just "12$1_test=$2" as the substitution produces the right 
result: "variable_test=value"


Another Question: Why does "subst()" use $x as backreference, otherwise "\x" is 
used?

-Sascha Spiekermann

Mime
View raw message