Assume I have a text file containing several lines with patterns like
xyz, ab, abc, zyx
ab, abc, zyx
xyc, ab, abc
xyz, ab, zyx
ab, zyx
xyc, ab
xyz, abc, zyx
abc, zyx
xyc, abc
I want to create a query that matches all lines which contain “ab”, but not those which contain only “abc” but not “ab”.
I have tried the following query:
Contains "ab" AND NOT Contains "abc"
OR
Contains "AB" AND Contains "abc"
However, to my surprise this only yields lines which only contain “abc” without “ab”, i.e. something like the logical inverse of what I wanted to achieve. My feeling is that this is because “ab” and “abc” are overlapping terms which might cause some (to me) unexpected side effect. The obvious solution would be “give me all btut the results from above”. Unfortunately the system in which I create the query will not allow me to create such a query, where I negate a whole term as the one above.
If yomeone has a better solution and/or an explantion why my query does not work as expected, I would be really happy.