Hello Daniel,

sorry for the delay - I had to do a business travel.


> You need to recalculate the begin/end offset info as well (the
> toUppercase test works because the offset information was the same).
> That's why I said if you can implement it in a generic way, it's
> something I think we should definitely add to the API.  It'll make
> life easier for anyone who wants to do this in the future.

Good to hear. When will it be available?


> If you see a way of improving the
> API to make it easire to apply arbitrary modifications to match
> results before substitution, don't hesitate to make a suggestion.

My idea was the following:

I wrote another substitute-method with an additional Param, a
java.lang.reflect.Method-Array. This Array contains a modifing Method
for each back-reference ([0] for $1, [1] for $2, etc.).
The assumption is that these methods are static, take a String-Param
and returns a String, too (like System.getProperty(String)).

My new group-method in MyMatchResult would look like this:

    try {

      Method actMethod = this.backRefModifyMethods[group];

      Object[] modifingMethodArgs = new Object[1];
      modifingMethodArgs[0] = this.orgMatchResult.group(group);

      String modifiedBackRef =
              (String)actMethod.invoke(null, modifingMethodArgs);

      return(modifiedBackRef);
    }
    catch(Exception e) {

      e.printStackTrace();
      throw(new RuntimeException());
    }


Maybe you should add a Construktor to Perl5Util, where I can force
a different Substitution-Object.
I had to modify Perl5Util like this:

    substitution =
      new MyPerl5Substitution(replacement.toString(), numInterpolations,
              backRefModifyMethods);


to use my own Perl5Subsitution-implemetation. A Constructor with this
option would make life easier, too.

Best regards
Stephan


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to