Tuesday, November 23, 2010

Re: Regular Expression question

On Nov 22, 3:14 pm, "Benjamin R. Haskell" <v...@benizi.com> wrote:
>
> You're looking for a "negative lookahead":
>
> :help /\@!
>
> For your case:
>
> /^.*word1\&\(.*word2\)\@!
>

Since \@! is zero-width you don't actually need the \& :

/^\(.*word2\)\@!.*word1

I still it is more obvious though to test for each part separately.
Still, using this regex, solving the OP's problem statement takes only
one command:

:g/^\(.*word2\)\@!.*word1

(default command for :g is :print)

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments:

Post a Comment