The regex should be:
TRACE_BR\(TRACE(?!.*END).*?%.*
This regex will not match the line if END
is a substring appearing after TRACE
. You may need to modify the regex if you want a more refined matching.
You can think of the regex as: after I matched TRACE
(and etc. in front), from the current position, I would like to look ahead that I cannot find END
substring.
In your regex, if the character after the negative look-ahead assertion is %
, the assertion is always true as END
substring can't start there; if the character after the negative look-ahead assertion is not %
, the regex will fail to match and backtrack.
In the hypothetical case that you remove the %
, the regex will still allow a string with END to pass, since the sequence of any character .*?
will allow the negative look ahead to match at any position along the way, and it can just find a position that is not the start of the string END
and match it.