Problem with Perl5Substitution

"ravi" <[email protected]> Wed, 7 May 2003 14:35:36 -0500
Newsgroups gmane.comp.jakarta.oro.user
Message-ID <000001c314cf$d77c9e00$2a00a8c0@htsony>
I have tried to use Perl5Substitution class to do the following
substitution. 
 
All I wanted to do is to insert a blank space before some special
strings like 's,'ll in the given string. This is the piece of the code
that I used to do this.
 
PatternMatcher matcher = new Perl5Matcher();
PatternCompiler compiler = new Perl5Compiler();
match = "('s|'d|'m|'ll|'re|'ve|n't)([^A-Za-z0-9])";
sub               = " $&";
input             = "let's hope he'll do the best";
Pattern pattern = null;
Perl5Substitution substitution = new Perl5Substitution(sub);
try {
  pattern = compiler.compile(match);
}
catch(MalformedPatternException e){
              System.err.println("Bad pattern.");
              System.exit(1);
}
input=Util.substitute(matcher,pattern,substitution,input,Util.SUBSTITUTE
_ALL);
 
But instead of returning "let 's hope he 'll do the best", it returned
me "let $&hope he $&do the best". i.e. It's just replacing the match
string with $& instead of inserting a blank space before it...
 
Can somebody help me out?
 
Thanks,
Ravi.