non-greedy pattern matching

2006-08-16 Thread Wolfgang Schmidt
Hi vimmers, 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.

Re: non-greedy pattern matching

2006-08-16 Thread A. S. Budden
On 16/08/06, Wolfgang Schmidt [EMAIL PROTECTED] wrote: Hi vimmers, 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 Try: s/^ignore

Re: non-greedy pattern matching

2006-08-16 Thread Tim Chase
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 s close. :) The \{-} is a *replacement* for the asterisk operator, not a

Re: non-greedy pattern matching

2006-08-16 Thread Jürgen Krämer
Hi, 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,