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
Got a patch from Tobias, applied to CVS. Added test to the retest.java. Please check.
I cannot remember exactly why I used $x. pro: "$" does not need to be escaped in java source code con: "\" is more commonly used. Bug is closed.
*** Bug 22966 has been marked as a duplicate of this bug. ***
*** Bug 36106 has been marked as a duplicate of this bug. ***