jakarta-regexp-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Holger Stratmann <Hol...@cheerful.com>
Subject Re: backreferences
Date Wed, 03 Apr 2002 11:55:22 GMT
Hi prasanna (sorry, which is the first name?),

> RE r = new RE("foo_([0-9]{2}).xml");
> String new = r.subst("foo_28.xml", "blah_\1.xml");
> Doesn't work.   i get blah_\1.xml

Well... the reason for this is obvious (sadly enough):
RegExp does NOT support replacing backreferences...

> any suggestions would be appreciated.

I faced the same problem a few weeks ago and since I wanted to stick with the
"lightweight" regexp, I implemented backrefs for myself. It's not yet
"completely complete" (mostly, escaping backslashes is still missing). I'm
planning to take another look at it soon, finish it and also submit the code...
(along with a few other fixes and extensions)

Right now, I implemented the functionality by subclassing rather than modifying
RE.java (assuming there might be updates, I didn't want to "merge" my changes

If you (or anybody else?) want to have the sources, just send me an e-mail...
If you prefer using "standard packages", I guess you could use ORO...


To unsubscribe, e-mail:   <mailto:regexp-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:regexp-dev-help@jakarta.apache.org>

View raw message