Reputation: 163
I do not understand why if given the following line (vi with set list on)
10.0.6.5^IVirtual^IVmware^IHTTP, MS SQL, Windows SVC^IcpHelpdesk $
Why the following regex:
^I.*?^I
does not match the string 'Virtual' in my line above? I am using the regex below in my VI search and replace
:%s/^I.*?^I/replace/g
this returns no match however on the same string if I use
^I.*^I
I would get
10.0.6.5replaceIcpHelpdesk $
What I attempting to say with ^I.*?^I
is from the first tab character (^I
) match anything (with the dot except line breaks) zero or more times ( *?
) until you come to the next token with is the tab character (^I
)
I don't see what I am missing and any help would be appreciated. Thank you
Upvotes: 1
Views: 3812
Reputation: 47189
Are you talking about vim regex here? In that case the non-greedy quantifier is \{-}
:
\t.\{-}\t
Otherwise you can do it by not matching tab characters with a negation group:
\t[^\t]*\t
Upvotes: 1