


We use a specific regex construction (?#), named a called subpattern. Then (Word1) matches the string Word1, stored as group 1, due to the parentheses, ONLY IF followed by the first string Word2, found afterwards, also stored as group 2, due to the “Look-ahead” construction (?=.*?(Word2))Īfter the alternative symbol |, the case (?2)(?=.*?(?1)) just represents the opposite case, where we’re searching for the string Word2, followed, further on, with the string Word1. The search will be perform, in an insensitive case way ( If you need a sensitive search, just use the syntax (?s-i) ) ) special character matches, absolutely, any single character ( standard or EOL ) The syntax (?si), at beginning of the regex, are modifiers which ensures that : So, instead, you could use the regex (?si)(Word1)(?=.*?(Word2))|(?2)(?=.*?(?1)), which searches for, either, the words Word1 OR Word2, in an insensitive case way, if they are followed, further on, by the second specific word However when the general case where the two words Word1 and Word2 are located in different lines, a search, with the Find in Files dialog, does NOT display, in the Find Result panel, all the lines of the block, beginning with Word1 and ending with Word2 ( or the opposite ) but ONLY the first line of each multi-lines block.
