Wolfgang Schmidt wrote:
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
I tried to use \{-} to make the ".*" match non-greedy, but I get E62
and E476.
Of course there are other ways to match the capitalized words, like \S
or something similar,
but I'd like to know how to use non-greedy matching here.
Here's the substitute that you're looking for:
s/^ignore \(.\{-}\) .\{-} \(.*\)/matched:\1,\2/gc
.* means greedy match, any character
.\{-} means non-greedy match, any character
Regards,
Chip Campbell