Hello, @ronny-kerk, @andrecool-68, @meta-chuh, @ekopalypse, @alan-kilborn and All,
Here is a general method to list all files which contains word1 AND word2 AND word3 AND … wordN. The + of that solution is it should be fast enough and that you do not need to worry about regex problems, as the use of the (?s) syntax, look-arounds, and the order of the different words to match :-))
In addition, even if you were about to look for 3 expressions, simultaneously, with a regex, you should have to test the different ranges, below :
Word3........Word1..........Word2
Word3........Word2..........Word1
Word1........Word3..........Word2
Word2........Word3..........Word1
Word1........Word2..........Word3
Word2........Word1..........Word3
Rather fastidious, isn’t it ?
So, in short, the different steps, of that general method, are :
Search, in Normal mode, of each expression word1, word2,…,wordN and successive outputs in the Find result panel
Paste of all the contents of the Find result panel in a new tab
Use of a first regex S/R, in order to keep the absolute pathnames, only
Alphabetic sort of these pathnames
Use of a second regex S/R, to isolate the pathnames which are present N times
Use of a third regex S/R to delete all the other pathnames, which do not contain the N words simultaneously
OK, let’s go :
Open the Find ( Ctrl + F ) or the Find in Files dialog ( Ctrl + Shift + F )
Search, successively, for the expressions word1, word2 … wordN
Tick, if necessary, the Match whole word only and/or the Match case options
Tick the Wrap around option
Select, preferably, the Normal search mode
Click, either, on the Find All in All Opened Documents or the Find All button
=> After the N consecutive searches, you’ll get N searches in the Find result panel
In the Find resul panel, select all the text ( Ctrl + A ) and copy it in the clipboard ( Ctrl + C )
Open a new tab ( Ctrl + N ) and paste the clipboard’s contents ( Ctrl + V )
Open the Replace dialog ( Ctrl + H )
Perform the following regex S/R, to keep, only, the different absolute pathnames
SEARCH (?-is)^(\t|Search).+\R|\x20\(\d+\x20hits?\)$
REPLACE Leave EMPTY
Tick the Wrap around option
Select the Regular expression search mode
Click on the Replace All button
Now, let’s sort that text, with the option Search > Line Operations > Sort Lines Lexicographically Ascending
Add a manual line-break at the very end of that sorted list ( IMPORTANT )
Perform this second
regex S/R, to detach the
only pathnames present,
N times
SEARCH (^.+\R)\1{N-1} , where N represents the number of the searched expressions
REPLACE \1\r\n ( or \1\n if Unix files )
Tick the Wrap around option
Click on the Replace All button
So, for a search of any file, containing 4 expressions/words, just use the search regex (^.+\R)\1{3}
Finally, using the final
regex S/R, below, you’ll obtain the
expected list, after
suppression of the
unwanted pathnames, and
line-breaks :
SEARCH ^.+\R(?!\R)|\R(?=\R)
REPLACE Leave EMPTY
Tick the Wrap around option
Click on the Replace All button
You’ll get, the list of all the absolute pathnames of files containing, at least once, all the words word1, word2 … wordN, in any order !
Of course, you may search for expressions more complicated than simple words, using the Regular expression search mode !
Best Regards,
guy038