On Mon, 12 Jun 2006, Gerald Lai wrote:
On Mon, 12 Jun 2006, Yakov Lerner wrote:
On 6/12/06, Tim Chase <[EMAIL PROTECTED]> wrote:
> I need to match lines using g// (not v//); those lines having
> 'foo' and NOT having /)\s*;/ anywhere in the line. How do I
> write such regex.
Well, there are several ways to go about it. One would be to use
Dr. Chip's "logipat" script:
http://vim.sourceforge.net/scripts/script.php?script_id=1290
LogiPat does wonders. Thanks.
For the record,
:echo LogiPat('"foo"&!"bar"')
produces:
\%(.*foo.*\&^\%(\%(bar\)[EMAIL PROTECTED])*$\)
Yakov
In addition to the regex above, you can also do:
/^\%(.*)\s*;\)[EMAIL PROTECTED]
It's a little shorter, and probably a little faster since the LogiPat
regex does a \%(..\)* for every character position of the line. The
speed is evident for a long line.
It follows the general form of a negative line search for embedded
<search>:
/^\%(.*[<limit0>.*]<search>[.*<limit1>]\)[EMAIL PROTECTED]
For example, to match a line that contains "foo" but does not contain
"bar" between "big" and "tummy":
/\%(.*big.*bar.*tummy\)[EMAIL PROTECTED]
Sorry, I missed the ^ anchor:
/^\%(.*big.*bar.*tummy\)[EMAIL PROTECTED]
--
Gerald