Page 1 of 1

Negative logic

Posted: Wed Nov 17, 2021 6:34 am
by frogman7
I want to find text but exclude in the find certain text:

<tag>1234567890qwerty1234567890</tag>
<tag>1234567890qwerty1111117890</tag>
<tag>1234567890qwerty1234567890</tag>
<tag>1234567890qwerty1234567890</tag>


In my find I want to search for <tag>[^<>]+ NOT 111111</tag>

so my search only finds lines 1, 3, and 4.

Is there a way to do this?

Re: Negative logic

Posted: Wed Nov 17, 2021 8:43 pm
by adrian
Hello,

I'm guessing you actually mean <tag>[^<>]+ NOT 1111117890</tag>
In that case it works with a regular expression like this (zero-width negative look-behind):
<tag>[^<>]+(?<!1111117890)</tag>

If you have wildcards on both sides of the negated string, it won't work.
e.g.
<tag>[^<>]+(?<!111111)[^<>]+</tag>
This may seem ok in theory, but it's not working in practice.

Regards,
Adrian