Friday, March 6, 2015

Re: Search pattern while excluding some words

On 2015-03-06 15:59, John Cordes wrote:
> I had looked at the "\@!" construction a bit (obviously
> not thoroughly enough) but had thought it would only
> exclude those 'words' if they were *immediately* followed
> by the search pattern. So I thought it would skip past
> something like this: SPCATUVW -- or that it might skip the
> whole line if one of the key 'words' was in the line.
> Evidently I've misunderstood something, so I'll try
> reading about it again.

The "\@!" roughly translates as "the atom right before me? It's not
allowed to match at this place". It's zero-width, so the
remainder of the pattern starts matching right were the assertion
would have started. Which is why
"\<\(RCMP\|QEII\|SPCA\)\@![A-Z]\{4,}\>" matches "WASPCAT", because
the disqualified "SPCA" doesn't come at the beginning.

Hope that clarifies a bit.

-tim


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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: