I'm trying to do a regexp replacement. My original line is

ignore MATCH1 ignore_again MATCH2

I want to match MATCH1 and MATCH2, so here's my trial:

s/^ignore \(.*\{-}\) .*\{-} \(.*\)/matched:\1,\2/gc

You're soooo close. :) The \{-} is a *replacement* for the asterisk operator, not a modifier for it (like the question-mark in PCREs). Thus, you want

s/^ignore \(.\{-}\) .\{-} \(.*\)/matched:\1,\2/gc

instead of

s/^ignore \(.*\{-}\) .*\{-} \(.*\)/matched:\1,\2/gc


-tim




Reply via email to