in reply to Re: How to do regex backreferences within $variable replacement text?
in thread How to do regex backreferences within $variable replacement text?

Ok, this appears to be working, except for one thing: for the backreferenced sections, spaces are getting prepended with a backslash in the $to clause, and subsequently in the $string. Here's a test I added:
[ 'Once upon a time, Jack Roush was not the king of the NASCAR garage, + but a stock-car outsider from Michigan trying to start a Winston Cup + team with a small-time budget.', '(king of the NASCAR )(garage, but +a stock-car)', 'HERE1$1HERE2$2HERE3' ]
And here's the output:
[Once upon a time, Jack Roush was not the king of the NASCAR garage, b +ut a stock-car outsider from Michigan trying to start a Winston Cup t +eam with a small-time budget.] ... [Once upon a time, Jack Roush was not the HERE1king\ of\ the\ NASCAR\ +HERE2garage\,\ but\ a\ stock\-carHERE3 outsider from Michigan trying +to start a Winston Cup team with a small-time budget.]

Any ideas? I can't see where these backslashes are coming from...!