Re: regexp (vim6)



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')
.



Relevant Pages

  • Re: perl file parsing
    ... AGGACATGCGGCCCGGCGACCTCATCATCTACTTCGACGACGCCAGCCACGTCGGGATG ... the number of times the pattern has occured. ... chomp; #remove newline characters ...
    (perl.beginners)
  • Re: Calculate Last Digits
    ... This might work faster by adding the following line at this point: ... Exit For, as discussed at enormous length in older threads, but this is ... I did get a big boost by switching from strings to longs for the pattern ...
    (microsoft.public.vb.general.discussion)
  • what are the USERID,PASSWD in /etc/passwd
    ... echo "Usage: `basename $0` USERNAME" ... exit $E_WRONGARGS ... file_excerpt $pattern ...
    (comp.unix.shell)
  • Re: perl file parsing
    ... my $fastaFile = 'myfile'; ... my $pattern = 'CTTGGCGAGAAGGGCCGCTACCTGCTGGCCGCCTCCTTCGGCAACGT'; ... chomp; #remove newline characters ...
    (perl.beginners)