On Wed, 10 Mar 2010, James Beck wrote:
> Hi,
>
> This might just drive me crazy. I've been trying to match lines that
> do NOT contain the word CODE.
>
> \(^.*\<CODE\>.*$\)\...@!
> If I take away the /@!, it matches all the lines that I'm looking to exclude!
Try:
^\(\(\<CODE\>\)\...@!.\)*$
That is:
lines: ^___$
...that consist of 0 or more characters \(___.\)*
...at which the word CODE: \<CODE\>
...is not matched: \(___\)\...@!
Before, you were getting:
*all positions that don't match*: \(___\)\...@!
...a whole line: ^___$
...that contains optional stuff: .*___.*
...and the word CODE: \<CODE\>
So, even the line 'CODE' would match, because, at the 'O', 'D', or 'E'
in CODE, there's not a whole line (anchored by the '^') that doesn't match CODE.
Via :help \...@!, a similar explanation:
You can't use "\...@!" to look for a non-match before the matching
position: "\(foo\)\...@!bar" will match "bar" in "foobar", because at
the position where "bar" matches, "foo" does not match.
Except in this case, instead of 'bar', it's the empty pattern that
matches.
--
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