On Sun, 24 Apr 2011, howard Schwartz wrote:
I want to match lines that contain the word, DEBIT but do not contain
the word PPD. How to I construct a pattern that will do this?
For example the pattern should exclude a line like,
DEBIT, this is a line with PPD in it
But the pattern should match:
DEBIT, this is a line without a certain word in it.
You're looking for a 'negative lookahead':
/^\%(.*PPD\)\@!.*DEBIT
/ - match
^ - beginning of line
\%( - start of non-capturing group
.* - any number of characters that aren't newlines
PPD - the string 'PPD'
\) - close of the group
\@! - negative lookahead (see :help /\@! )
.* - any number of characters that aren't newlines
DEBIT - the string 'DEBIT'
Paraphrased into English:
Match from the start of the line anything followed by DEBIT, but not
when you see anything followed by PPD.
--
Best,
Ben
--
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