Tuesday, November 1, 2011

How do I search for pattern A followed by NOT pattern A ?

Hi

Apologies if this has come up already, but I had a search through the
posts and could not see the answer.

How can I search for a line with pattern A directly followed by a line
that does not have the previous pattern A ?

For example, if I have the buffer below,

ppppp 1 2 3 4 5
ppppp 1 2 3 4 5
ppppv 1 2 3 4 5
ppppp 1 2 3 4 5

I can type the search

/\(ppppp\).*\n\1.*

which will match against the first two lines

However, I want to pick out lines 2 and 3. How can I do that ?

I had tried something like,

/\(ppppp\).*\n\1\{0}.*

to match the captured characters zero times, but that did not work (I
guess i am looking for something I can use like a NOT operator)

Thanks for any help.

--
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