At execution org.apache.regexp. RE.substr (substIn, substOut, REPLACE_ALL) "bites off" first two symbols of substOut if substOut contains $0-$9. Also, if substOut contains $0-$9 from a position less than 2, subst(.. falls with StringOutOfBoundsException: String index out of range: -2 (or -1).
It looks like this is a duplicate of 25985 (In MATCH_MULTILINE-mode $ does not match end of line). Could you, please, test with current development version, or provide testcase to reproduce the problem.
I'm downloading jakarta-regexp-20040316.jar. No error detected :)
*** This bug has been marked as a duplicate of 25985 ***