Capture string in regex replacement
问题 From what I can gather from the Pharo documentation on regex, I can define a regular expression object such as: re := '(foo|re)bar' asRegex And I can replace the matched regex with a string via this: re copy: 'foobar blah rebar' replacingMatchesWith: 'meh' Which will result in: `'meh blah meh'. So far, so good. But I want to replace the 'bar' and leave the prefix alone. Therefore, I need a variable to handle the captured parenthetical: re copy: 'foobar blah rebar' replacingMatchesWith: '%1meh