On Fri, 31 Mar 2006 at 7:13am, Dave Roberts wrote:
> Charles E Campbell Jr wrote:
> > Dave Roberts wrote:
> >> Is it possible to match a pattern only if it does not contain another
> >> specified pattern anywhere in it?
> >> For example, match a 'foo' followed by a 'bar' as long as there is no
> >> 'dave' between the foo and bar.
> >> So this foo line matches bar according to dave (no embedded dave)
> >> but this foo line, according to dave, doesn't match bar. (embedded dave)
> >> It's easy enough to match if the pattern is in a specific place but
> >> how to match (or not) if the pattern can be anywhere?
> >> Apologies if this is described right in front of me in "pattern.txt"
> >> - it's getting late...
> > Try LogiPat,
> > http://vim.sourceforge.net/scripts/script.php?script_id=1290 .
> > It provides !, & and | (logical not, logical and, logical or)
> > operators and () for grouping.
> > :LP !"foo.*dave.*bar"
> > Regards,
> > Chip Campbell
> I've looked at LogiPat before and it's useful but I'm looking at these
> regular expressions to figure out how to do syntax coloring on a
> complicated multi-line pattern that can have the same start and end
> patterns but differ by embedded patterns that mean something different
> if they themselves have a match or not inside the pattern. I'm getting
> closer using \@! but am still having trouble in one place.
> If I can't figure it out I'll post the whole thing eventually to let
> someone else have a crack at at.
> - Dave
The way I usually manage with -ve part of the patterns is that I first
search without that and get the matching lines in a separate window, and
further narrow them by remove the lines matching the -ve pattern. This
requires multiple steps, and might not always suit your needs, but it
usually is simple enough. You can use grep to generate errorlist and
work on the error-list window, but I prefer to use my greputils plugin
to redirect the :g/re/p result to a window.
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around