Friday, March 6, 2015

Re: Search pattern while excluding some words

On Fri, Mar 06, 2015 at 03:19:25PM -0600, Tim Chase wrote:
> 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

Yes it does -- thanks Tim.

I have also re-read the documentation on "\@!" and think
I understand it better now:

Matches with zero width if the preceding
atom does NOT match at the current
position.

I hadn't appreciated, till seeing it in action, just how
to interpret the phrase 'match at the current position'.

John


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

Post a Comment