Friday, March 6, 2015

Re: Search pattern while excluding some words

On 2015-03-06 15:30, John Cordes wrote:
> in vim and search for surnames which may have remained
> embedded within a paragraph; I use
>
> /[A-Z]\{4,\}
>
> for this (ignoring the occasional 3 letter surname).
>
> Here's my question: while running this search on 4 or
> more uppercase characters, I would like to be able to skip
> past (ignore) certain commonly occurring 'words' such as
> RCMP, QEII, SPCA and such. I want to jump immediately to
> the next occurring surname.

Try

/\(RCMP\|QEII\|SPCA\)\@![A-Z]\{4,}

The \(...\) groups alternatives of things you don't want, and the
"\@!" asserts that it can't match at the start. It does have some
edge cases like good MR. WASPCALL (contains "SPCA" which you may or
may not want) or if you have an exclusion that can begin a legit name.
You can tighten it a bit with

\<\(RCMP\|QEII\|SPCA\)\@![A-Z]\{4,}\>

Hopefully this gets you where you need to go.

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