I am using notepad++ to search for certain keywords (using regular expression). something like (word1|word2|this statement|another statement). It works but can I search and show all results except a certain keyword? something like exclude the following words (exclude this|exclude this)? For example, below.
samedir\File1.log
This is line 1
This is line 2
This is line 3
exclude this
This is line 4
This is line 5
This is line 6
not excluded
excluding this
samedir\File2.log
This is line 1 1
This is line 2 1
This is line 3 1
exclude this
This is line 4 1
This is line 5 1 1
This is line 6 1
not excluded
excluding this
For example: I want to start a find in both files (on the same directory) but exclude the lines with excluding this
and exclude this
the results should show something like below
File1.log
This is line 1
This is line 2
This is line 3
This is line 4
This is line 5
This is line 6
not excluded
File2.log
This is line 1 1
This is line 2 1
This is line 3 1
This is line 4 1
This is line 5 1 1
This is line 6 1
not excluded
You could try the regex like below to match all the lines which don't have exclude
or excluding this
strings.
^(?!.*\bexclud(?:ing|e) this\b).+$
This (?!.*\bexclud(?:ing|e) this\b)
negative lookahead at the start asserts that there isn't a string exclude this
or excluding this
present on the the line in which we are going to match. That is , the above regex would match all the lines except the one which contains exclude this
or excluding this