1
I've searched through all of the TextPad regex postings on superuser.com and have not found an answer to my query. It is -- how can I provide two conditions in a TextPad 8 file search regular expression? In particular, I want to find all lines in all files that contain the strings Error or Warning, which I can do using the regex error|warning
, but in addition to that, I want to select only the subset of those lines where another specified text string, e.g. expir
, is not present anywhere on the lines, before or after the location of the matching string from the first regex.
I've tried various forms of putting a conjunction like &
or &&
between the two regexes, but cannot find a syntax that works. Do TextPad regular expressions include support for lookahead and lookbehind zero-width assertions? In perl, I could say
(?<!expir).*?error|warning(?!.*?expir)
. I entered that in TextPad, and it caused no errors, but it also did not work. It selected all of the lines that contained either error
or warning
but did not exclude lines that also contained expir
.
To test if something is NOT present, you have to use this construction:
((?!expir).)*
so your regex becomes:^((?!expir).)*(?:error|warning)((?!expir).)*$
– Toto – 2017-09-20T09:47:50.427