Re: regexp (vim6)
- From: Preben 'Peppe' Guldberg </bin/vi@xxxxxxxxxxxx>
- Date: 11 Nov 2005 18:54:38 GMT
John Degen wrote:
> Joachim Hofmann <speicher@xxxxxxxxxx> wrote in
> news:3tec2mFsj7kvU1@xxxxxxxxxxxxxx:
> > How can I match all lines containing "Function" but excluding lines
> > containing "Exit Function" or "End Function" ?
> See Peppe's reply below. I don't quite understand this, but I think it very
> similar to the previous question:
> /\<\%(Exit\|End\)\@!\w*Function\>/
In this case, I'd probably change that to
/\<\%(Exit\|End\)\@!\w\+\s\+Function\>/
Breaking it down, it goes
/ Search forward for ...
\< Beginning of a word
\%( A non-captured group of
Exit\|End Exit or End
\)\@! That is _not_ present
\w\+ Followed by multiple word characters (":h /\w")
\s\+ Followed by multiple whitespace characters
Function The word Function
\> End of word after Function
/ End of search pattern
However, that does not match lines that start with Function. For that
you would have to do something slightly different:
/\<\%(\<\%(Exit\|End\)\s\+\)\@<!\<Function\>/
The crucial difference is the < in \@<! which looks backwards. This
pattern would match Function, unless preceeded by Exit or End - which is
quite different from the previous pattern which matches Any word but
Exit or End, followed by Function.
It's tricky business. If you would like me to expand further, please let
me know.
Peppe
--
se nocp cpo=BceFsx!$ hid bs=2 ls=2 hls ic " P. Guldberg /bin/vi@xxxxxxxxxxxx
se scs ai isf-== fdo-=block cino=t0,:0 hi=100 ru so=4 noea lz|if has('unix')
se sh=/bin/sh|en|syn on|filetype plugin indent on|ono S V/\n^-- $\\|\%$/<CR>
cno <C-A> <C-B>|au FileType vim,mail se sw=4 sts=4 et|let&tw=72+6*(&ft=~'v')
.
- References:
- regexp (vim6)
- From: Joachim Hofmann
- Re: regexp (vim6)
- From: John Degen
- regexp (vim6)
- Prev by Date: Re: VIM 64 crypt incompatibilty!
- Next by Date: Vim modes
- Previous by thread: Re: regexp (vim6)
- Next by thread: gvim, vim -g, and cream
- Index(es):
Relevant Pages
|