<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Find only files with exact two words]]></title><description><![CDATA[<p dir="auto">I have a lot of different files. Notepad++ should only find the files which inlude the two words i’m searching for.<br />
The two words are not located in the same line, just somewhere in the same file.</p>
<p dir="auto">How can i do this?</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/17426/find-only-files-with-exact-two-words</link><generator>RSS for Node</generator><lastBuildDate>Sat, 15 Aug 2026 01:22:38 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/17426.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 09 Apr 2019 09:39:34 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Find only files with exact two words on Wed, 10 Apr 2019 18:42:14 GMT]]></title><description><![CDATA[<p dir="auto">Hello, <a class="plugin-mentions-user plugin-mentions-a" href="/user/ronny-kerk" aria-label="Profile: ronny-kerk">@<bdi>ronny-kerk</bdi></a>, <a class="plugin-mentions-user plugin-mentions-a" href="/user/andrecool-68" aria-label="Profile: andrecool-68">@<bdi>andrecool-68</bdi></a>, <a class="plugin-mentions-user plugin-mentions-a" href="/user/meta-chuh" aria-label="Profile: meta-chuh">@<bdi>meta-chuh</bdi></a>, <a class="plugin-mentions-user plugin-mentions-a" href="/user/ekopalypse" aria-label="Profile: ekopalypse">@<bdi>ekopalypse</bdi></a>, <a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: alan-kilborn">@<bdi>alan-kilborn</bdi></a> and <strong>All</strong>,</p>
<p dir="auto">Here is a <strong>general</strong> method to <strong>list all</strong> files which contains <strong><code>word1</code></strong> AND <strong><code>word2</code></strong> AND <strong><code>word3</code></strong> AND … <strong><code>wordN</code></strong>. The <strong><code>+</code></strong> of that solution is it should be <strong>fast</strong> enough and that you do <strong>not</strong> need to worry about regex <strong>problems</strong>, as the use of the <strong><code>(?s)</code></strong> syntax, <strong>look-arounds</strong>, and the <strong>order</strong> of the <strong>different</strong> words to match :-))</p>
<p dir="auto">In addition, <strong>even</strong> if you were about to look for <strong><code>3</code></strong> expressions, <strong>simultaneously</strong>, with a regex, you should have to test the <strong>different</strong> ranges, below :</p>
<p dir="auto"><strong><code>Word3........Word1..........Word2</code></strong><br />
<strong><code>Word3........Word2..........Word1</code></strong><br />
<strong><code>Word1........Word3..........Word2</code></strong><br />
<strong><code>Word2........Word3..........Word1</code></strong><br />
<strong><code>Word1........Word2..........Word3</code></strong><br />
<strong><code>Word2........Word1..........Word3</code></strong></p>
<p dir="auto">Rather <strong>fastidious</strong>, isn’t it ?</p>
<hr />
<p dir="auto">So, in short, the different <strong>steps</strong>, of that <strong>general</strong> method, are :</p>
<ul>
<li>
<p dir="auto">Search, in <strong><code>Normal</code></strong> mode, of <strong>each</strong> expression <strong><code>word1</code></strong>, <strong><code>word2</code></strong>,…,<strong><code>wordN</code></strong> and <strong>successive</strong> outputs in the <strong><code>Find result</code></strong> panel</p>
</li>
<li>
<p dir="auto">Paste of <strong>all</strong> the contents of the <strong><code>Find result</code></strong> panel in a <strong>new</strong> tab</p>
</li>
<li>
<p dir="auto">Use of a <strong>first</strong> regex S/R, in order to keep the absolute <strong>pathnames</strong>, <strong>only</strong></p>
</li>
<li>
<p dir="auto">Alphabetic <strong>sort</strong> of these <strong>pathnames</strong></p>
</li>
<li>
<p dir="auto">Use of a <strong>second</strong> regex S/R, to <strong>isolate</strong> the pathnames which are <strong>present</strong> <strong><code>N</code></strong> times</p>
</li>
<li>
<p dir="auto">Use of a <strong>third</strong> regex S/R to <strong>delete</strong> all the other pathnames, which do <strong>not</strong> contain the <strong><code>N</code></strong> words <strong>simultaneously</strong></p>
</li>
</ul>
<hr />
<p dir="auto">OK, let’s go :</p>
<ul>
<li>
<p dir="auto">Open the <strong>Find</strong> ( <strong><code>Ctrl + F</code></strong> ) or the <strong>Find in Files</strong> dialog ( <strong><code>Ctrl + Shift + F</code></strong> )</p>
</li>
<li>
<p dir="auto">Search, <strong>successively</strong>, for the expressions <strong><code>word1</code></strong>, <strong><code>word2</code></strong> … <strong><code>wordN</code></strong></p>
</li>
<li>
<p dir="auto"><strong>Tick</strong>, if necessary, the <strong><code>Match whole word only</code></strong> <strong>and/or</strong> the <strong><code>Match case</code></strong> options</p>
</li>
<li>
<p dir="auto"><strong>Tick</strong> the <strong><code>Wrap around</code></strong> option</p>
</li>
<li>
<p dir="auto">Select, <strong>preferably</strong>, the <strong><code>Normal</code></strong> search mode</p>
</li>
<li>
<p dir="auto">Click, <strong>either</strong>, on the <strong><code>Find All in All Opened Documents</code></strong> or the <strong><code>Find All</code></strong> button</p>
</li>
</ul>
<p dir="auto">=&gt; After the <strong><code>N</code></strong> <strong>consecutive</strong> searches, you’ll get <strong><code>N</code></strong> searches in the <strong><code>Find result</code></strong> panel</p>
<hr />
<ul>
<li>
<p dir="auto">In the <strong><code>Find resul</code></strong> panel, select all the text ( <strong><code>Ctrl + A</code></strong> ) and copy it in the <strong>clipboard</strong> ( <strong><code>Ctrl + C</code></strong> )</p>
</li>
<li>
<p dir="auto">Open a <strong>new</strong> tab ( <strong><code>Ctrl + N</code></strong> ) and <strong>paste</strong> the clipboard’s contents ( <strong><code>Ctrl + V</code></strong> )</p>
</li>
<li>
<p dir="auto">Open the <strong>Replace</strong> dialog ( <strong><code>Ctrl + H</code></strong> )</p>
</li>
<li>
<p dir="auto">Perform the following <strong>regex</strong> S/R, to keep, <strong>only</strong>, the different <strong>absolute pathnames</strong></p>
</li>
</ul>
<p dir="auto">SEARCH <strong><code>(?-is)^(\t|Search).+\R|\x20\(\d+\x20hits?\)$</code></strong></p>
<p dir="auto">REPLACE <strong><code>Leave EMPTY</code></strong></p>
<ul>
<li>
<p dir="auto"><strong>Tick</strong> the <strong><code>Wrap around</code></strong> option</p>
</li>
<li>
<p dir="auto">Select the <strong><code>Regular expression</code></strong> search mode</p>
</li>
<li>
<p dir="auto">Click on the <strong><code>Replace All</code></strong> button</p>
</li>
<li>
<p dir="auto">Now, let’s <strong>sort</strong> that text, with the option <strong><code>Search &gt; Line Operations &gt; Sort Lines Lexicographically Ascending</code></strong></p>
</li>
<li>
<p dir="auto">Add a manual <strong>line-break</strong> at the <strong>very end</strong> of that <strong>sorted</strong> list ( IMPORTANT )</p>
</li>
</ul>
<hr />
<ul>
<li>Perform this second <strong>regex</strong> S/R, to detach the <strong>only</strong> pathnames present, <strong><code>N</code></strong> <strong>times</strong></li>
</ul>
<p dir="auto">SEARCH <strong><code>(^.+\R)\1{</code>N-1<code>}</code></strong> , where <strong>N</strong> represents the <strong>number</strong> of the <strong>searched</strong> expressions</p>
<p dir="auto">REPLACE <strong><code>\1\r\n</code></strong> ( or <strong><code>\1\n</code></strong> if <strong>Unix</strong> files )</p>
<ul>
<li>
<p dir="auto"><strong>Tick</strong> the <strong><code>Wrap around</code></strong> option</p>
</li>
<li>
<p dir="auto">Click on the <strong><code>Replace All</code></strong> button</p>
</li>
</ul>
<p dir="auto">So, for a search of any file, containing <strong><code>4</code></strong> expressions/words, just use the search <strong>regex</strong> <strong><code>(^.+\R)\1{3}</code></strong></p>
<hr />
<ul>
<li>Finally, using the final <strong>regex</strong> S/R, below, you’ll obtain the <strong>expected</strong> list, after <strong>suppression</strong> of the <strong>unwanted</strong> pathnames, and <strong>line-breaks</strong> :</li>
</ul>
<p dir="auto">SEARCH <strong><code>^.+\R(?!\R)|\R(?=\R)</code></strong></p>
<p dir="auto">REPLACE <strong><code>Leave EMPTY</code></strong></p>
<ul>
<li>
<p dir="auto"><strong>Tick</strong> the <strong><code>Wrap around</code></strong> option</p>
</li>
<li>
<p dir="auto">Click on the <strong><code>Replace All</code></strong> button</p>
</li>
</ul>
<p dir="auto">You’ll get, the list of <strong>all</strong> the <strong>absolute pathnames</strong> of files containing, at least <strong>once</strong>, <strong>all</strong> the words <strong><code>word1</code></strong>, <strong><code>word2</code></strong> … <strong><code>wordN</code></strong>, in <strong>any</strong> order !</p>
<hr />
<p dir="auto">Of course, you may search for expressions more <strong>complicated</strong> than <strong>simple</strong> words, using the <strong><code>Regular expression</code></strong> search mode !</p>
<p dir="auto">Best Regards,</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/42158</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/42158</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Wed, 10 Apr 2019 18:42:14 GMT</pubDate></item><item><title><![CDATA[Reply to Find only files with exact two words on Wed, 10 Apr 2019 07:25:53 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: Alan-Kilborn">@<bdi>Alan-Kilborn</bdi></a> said:</p>
<blockquote>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/ronny-kerk" aria-label="Profile: Ronny-Kerk">@<bdi>Ronny-Kerk</bdi></a></p>
<p dir="auto">I would suggest this:</p>
<p dir="auto">Find: <code>(?si)(\bword1\b.*?\bword2\b)|(\bword2\b.*?\bword1\b)</code><br />
Search mode: Regular expression</p>
</blockquote>
<p dir="auto">Hello Alan,<br />
this is the solution. It works like it should. Thanks for your help.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/42129</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/42129</guid><dc:creator><![CDATA[Ronny Kerk]]></dc:creator><pubDate>Wed, 10 Apr 2019 07:25:53 GMT</pubDate></item><item><title><![CDATA[Reply to Find only files with exact two words on Tue, 09 Apr 2019 13:12:12 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: Alan-Kilborn">@<bdi>Alan-Kilborn</bdi></a></p>
<p dir="auto">thank you very much. I guess I understood :-)</p>
]]></description><link>https://community.notepad-plus-plus.org/post/42094</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/42094</guid><dc:creator><![CDATA[Ekopalypse]]></dc:creator><pubDate>Tue, 09 Apr 2019 13:12:12 GMT</pubDate></item><item><title><![CDATA[Reply to Find only files with exact two words on Tue, 09 Apr 2019 13:05:04 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/ekopalypse" aria-label="Profile: Ekopalypse">@<bdi>Ekopalypse</bdi></a> said:</p>
<blockquote>
<p dir="auto">where do you see the advantage of using alternations versus lookaheads?</p>
</blockquote>
<p dir="auto">I suppose for the current case of the OP, it doesn’t matter, but if I were doing it, I suspect I might like to see the <em>range</em> where my match was found, in certain instances.  The lookahead approach selects as a match the entire file contents. BTW, I’m always nervous when the regex engine causes an entire file contents match.  It makes me think it has failed in a big way…see <a href="https://github.com/notepad-plus-plus/notepad-plus-plus/issues/4761" rel="nofollow ugc">here</a>.</p>
<p dir="auto">If the 2 words need to occur on a single line (not the OP’s case!), I am not reluctant to use the lookahead approach, the classic example of which is <a href="https://stackoverflow.com/questions/4389644/regex-to-match-string-containing-two-names-in-any-order" rel="nofollow ugc">here</a>.  I always remember that one by recalling it is the “jack” approach. :)</p>
]]></description><link>https://community.notepad-plus-plus.org/post/42093</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/42093</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Tue, 09 Apr 2019 13:05:04 GMT</pubDate></item><item><title><![CDATA[Reply to Find only files with exact two words on Tue, 09 Apr 2019 12:50:26 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: Alan-Kilborn">@<bdi>Alan-Kilborn</bdi></a></p>
<p dir="auto">may I ask you, where do you see the advantage of using alternations versus lookaheads?</p>
]]></description><link>https://community.notepad-plus-plus.org/post/42092</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/42092</guid><dc:creator><![CDATA[Ekopalypse]]></dc:creator><pubDate>Tue, 09 Apr 2019 12:50:26 GMT</pubDate></item><item><title><![CDATA[Reply to Find only files with exact two words on Tue, 09 Apr 2019 12:29:16 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/ronny-kerk" aria-label="Profile: Ronny-Kerk">@<bdi>Ronny-Kerk</bdi></a></p>
<p dir="auto">I would suggest this:</p>
<p dir="auto">Find: <code>(?si)(\bword1\b.*?\bword2\b)|(\bword2\b.*?\bword1\b)</code><br />
Search mode: Regular expression</p>
<p dir="auto">The <code>\b</code> are there to enforce word boundaries–remove them if not desired.  Also this will find <code>word1</code> and <code>word2</code> in either order, and without regard to the case.</p>
<p dir="auto">So basically this:  <code>I’ve tried it but it does not work. It finds the two words i’m looking for, but just in a big section. Not in the whole file</code> doesn’t make a lot of sense.  How can it not work but yet find the 2 words you want?  Can you explain more about what you expect versus what happens?</p>
<p dir="auto">Note that Notepad++ can’t directly give you a list of files.  It can only give you a list of <em>matches</em>, which includes the filenames but also has more information about the matches.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/42086</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/42086</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Tue, 09 Apr 2019 12:29:16 GMT</pubDate></item><item><title><![CDATA[Reply to Find only files with exact two words on Tue, 09 Apr 2019 12:17:34 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/ronny-kerk" aria-label="Profile: Ronny-Kerk">@<bdi>Ronny-Kerk</bdi></a></p>
<p dir="auto">I’m not promoted to be an regex expert yet but what about using something like</p>
<p dir="auto"><code>(?s)(?=.*1982)(?=.*Ronny Kerk).*</code></p>
]]></description><link>https://community.notepad-plus-plus.org/post/42084</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/42084</guid><dc:creator><![CDATA[Ekopalypse]]></dc:creator><pubDate>Tue, 09 Apr 2019 12:17:34 GMT</pubDate></item><item><title><![CDATA[Reply to Find only files with exact two words on Tue, 09 Apr 2019 11:03:13 GMT]]></title><description><![CDATA[<p dir="auto">Thanks for your answer.<br />
I’ve tried it but it does not work. It finds the two words i’m looking for, but just in a big section. Not in the whole file.</p>
<p dir="auto">My files (ca. 1,500) are filled with many words. Most files have over 1000 lines. Now i want to give notepad two or maybe more words to look for. For example: “Ronny Kerk” and “1982” are the words i’m looking for. Now notepad should show me all the files where both these two search criterias are included.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/42080</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/42080</guid><dc:creator><![CDATA[Ronny Kerk]]></dc:creator><pubDate>Tue, 09 Apr 2019 11:03:13 GMT</pubDate></item><item><title><![CDATA[Reply to Find only files with exact two words on Tue, 09 Apr 2019 10:44:07 GMT]]></title><description><![CDATA[<p dir="auto">welcome to the notepad++ community, <a class="plugin-mentions-user plugin-mentions-a" href="/user/ronny-kerk" aria-label="Profile: Ronny-Kerk">@<bdi>Ronny-Kerk</bdi></a></p>
<p dir="auto">our regex specialists are currently offline, and i’m only at janitor level for regex, but here’s something you could try:</p>
<p dir="auto">open up <code>find in files</code> and enter:<br />
find what: <code>(?=.*word1)(?=.*word2)</code><br />
directory: <code>your desired path</code><br />
search mode: <code>regular expression</code><br />
and hit <code>find all</code></p>
]]></description><link>https://community.notepad-plus-plus.org/post/42077</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/42077</guid><dc:creator><![CDATA[Meta Chuh]]></dc:creator><pubDate>Tue, 09 Apr 2019 10:44:07 GMT</pubDate></item><item><title><![CDATA[Reply to Find only files with exact two words on Tue, 09 Apr 2019 10:28:57 GMT]]></title><description><![CDATA[<p dir="auto">Maybe this works, but i would like to do it in notepad. I had used it in notepad a few months ago, but i’ve forgot what i have to put in the search field in notepad. Tried some i found via google but nothing works the way i need it.</p>
<p dir="auto">It also finds files which include either one of the words. But i need to find files with both words in.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/42073</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/42073</guid><dc:creator><![CDATA[Ronny Kerk]]></dc:creator><pubDate>Tue, 09 Apr 2019 10:28:57 GMT</pubDate></item><item><title><![CDATA[Reply to Find only files with exact two words on Tue, 09 Apr 2019 10:02:19 GMT]]></title><description><![CDATA[<p dir="auto">There is the search words in files, he that does not work?</p>
]]></description><link>https://community.notepad-plus-plus.org/post/42071</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/42071</guid><dc:creator><![CDATA[andrecool-68]]></dc:creator><pubDate>Tue, 09 Apr 2019 10:02:19 GMT</pubDate></item></channel></rss>