in reply to Extracting regex from string

In your example, $1 seems to take the value 'world'. Where did that come from? It is not in either of your input strings. When is it interpolated? Please post a complete example with both the actual and the desired output.
Bill