Hello Vim List,
Trying out LogiPat (by Charles Campbell) today, I ran into a problem.
I tried to find lines that contain "abc" or "def" but didn't contain
both.
There are many ways to construct this search. I picked three methods
and show below, for each method, how I expressed the logic for
LogiPat, the pattern generated by LogiPat, and a pattern written by me
(line starting with "by hand").
Method 1
The LogiPat pattern finds any line with an "abc" or "def" including
lines with both. This is wrong.
echo LogiPat('("abc" | "def") & !("abc" & "def")')
\%(.*abc.*\|.*def.*\&^\%(\%(\%(.*abc.*\&.*def.*\)\)[EMAIL PROTECTED])*$\)
by hand: \v%(.*abc|.*def)&^%(.*abc&.*def)@!.*
Method 2
The LogiPat pattern appears to work.
echo LogiPat('("abc" & !"def") | ("def" & !"abc")')
\%(.*abc.*\&^\%(\%(def\)[EMAIL PROTECTED])*$\)\|\%(.*def.*\&^\%(\%(abc\)[EMAIL
PROTECTED])*$\)
by hand: \v^%(.*abc&%(.*def)@!|.*def&%(.*abc)@!).*
Method 3
The LogiPat pattern appears to find every line. This is wrong.
echo LogiPat('("abc" | "def") & (!"abc" | !"def")')
\%(.*abc.*\|.*def.*\&^\%(\%(abc\)[EMAIL PROTECTED])*$\|^\%(\%(def\)[EMAIL
PROTECTED])*$\)
by hand: \v^%(%(.*abc|.*def)&%(%(.*abc)@!|%(.*def)@!)).*
Are my logic descriptions for LogiPat incorrect?
Here's some text for testing these (only two lines should match):
start of test
have abc only <--
have def only <--
have both abc and def now
have both def and abc now
end of test
BTW, you can try any pattern by yanking it and typing: /^R"^M
where ^R is CTRL-R and ^M is <enter>.
--
Best regards,
Bill