Hello. I got into trouble using grouping and variables in regular expressions.
Given this scenario: s/search_for(but_preserve)/replace_with $1/; I can also do: $pattern = 'search_for(but_preserve)'; $replace = 'replace_with'; s/$pattern/$replace $1/; But I am unable to do: $pattern = 'search_for(but_preserve)'; $replace = 'replace_with $1'; s/$pattern/$replace/; It would be very helpful if I could to this as the grouping in the "$pattern" varies as well as the placement of the corresponding variables $1, $2, ... I tried to do it with eval() -- without any success. Does eval() make any sense here at all? Any help would be very much appreciated! TIA Pascal