In message <c73e01e3.1ddfd%[email protected]>, Brian Dantes writes:
>$x =~ s/abc(def)ghi(jkl)/${1}123${2}/;
>
>This doesn't work with ORO. Instead I have to:
>
>util.substitute("s/abc(def)ghi(jkl)/$1\\123$2/");
...
>Is there a way?

Try the attached patch.  I made it against the trunk, so it may need
a little adjustment for the last released version, but I think it
will apply cleanly against 2.0.8.  If you can confirm for me that the
patch works for you, I'll commit the change.  It's been a very
long time since I've looked at any of this code and I was about to
suggest you preprocess your expressions to transform them from the first
form to the second form, but it turned out the feature was a very quick
fix.  If anyone requires a formal release with the change, we can branch
off of 2.0.8 to cut a 2.0.9 release (the trunk contains incomplete
experimental changes), but I'm going to have to recruit some help from
another Jakarta committer to prepare an actual release as I'm extremely
short on time.  There's a bunch of non-coding stuff involved that has
changed since the last release, centering around the build system, web
page generation, and release requirement compliance that I just don't
have the time for right now.

daniel
Index: src/java/org/apache/oro/text/regex/Perl5Substitution.java
===================================================================
--- src/java/org/apache/oro/text/regex/Perl5Substitution.java	(revision 389827)
+++ src/java/org/apache/oro/text/regex/Perl5Substitution.java	(working copy)
@@ -165,7 +165,7 @@
   transient String _lastInterpolation;
 
   private static final boolean __isInterpolationCharacter(char ch) {
-    return (Character.isDigit(ch) || ch == '&');
+    return (Character.isDigit(ch) || ch == '&' || ch == '{');
   }
 
   private void __addElement(int value) {
@@ -220,13 +220,19 @@
 	    saveDigits = false;
 	    continue;
 	  }
-	}
+	} else if(c == '{') {
+          continue;
+        }
 
 	__addElement(posParam);
 	posParam = 0;
 	saveDigits = false;
-      } 
 
+        if(c == '}') {
+          continue;
+        }
+      }
+
       if ((c != '$' && c != '\\') || escapeMode) {
 	escapeMode = false;
 	if (offset < 0) {

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to