<?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 all lines that contain specific strings]]></title><description><![CDATA[<p dir="auto">Hello everyone<br />
I have text file and I would like to search for lines that has specific partial strings and shows only the lines that has those strings</p>
<h1>Example:</h1>
<p dir="auto">Please help me in this issue<br />
Thanks a lot for great help<br />
I receive help in this forum in great way. Please have a look<br />
You are great people<br />
Help me please<br />
in this line help is only exists<br />
these are some lines as an example<br />
these lines have to be searched by any string<br />
no case sensitive is required in search process</p>
<p dir="auto">I need to search for “pleas” and “help”</p>
<hr />
<h2>The expected lines that would be displayed :</h2>
<p dir="auto">Please help me in this issue<br />
I receive help in this forum in great way. Please have a look<br />
Help me please</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/14326/find-all-lines-that-contain-specific-strings</link><generator>RSS for Node</generator><lastBuildDate>Sat, 07 Nov 2026 02:25:31 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/14326.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 17 Aug 2017 17:25:08 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Find all lines that contain specific strings on Sun, 20 Aug 2017 22:48:12 GMT]]></title><description><![CDATA[<p dir="auto">Hello, @yasser-hhalil and <a class="plugin-mentions-user plugin-mentions-a" href="/user/scott-sumner" aria-label="Profile: scott-sumner">@<bdi>scott-sumner</bdi></a>,</p>
<p dir="auto">Sorry, I’m <strong>not</strong> very <strong>reactive</strong>, cause I’m on holidays, in <strong>North Brittany</strong>, with my two sisters and their husbands. What to say ? We make a cure of <strong>seafood</strong> : cockles, periwinkles, clams, lobsters, crabs and even octopus ! To sum up : the Paradise ;-))Since one week, weather was quite <strong>fine</strong>, here, but today it was raining. So, I’m back to <strong>N++</strong> and the <strong>Community</strong>, for a while !!</p>
<hr />
<p dir="auto">Ah, <a class="plugin-mentions-user plugin-mentions-a" href="/user/scott-sumner" aria-label="Profile: scott-sumner">@<bdi>scott-sumner</bdi></a>, very clever regex, found by <strong>Alin Purcaru</strong>, on <strong>Stackoverflow</strong> site !</p>
<p dir="auto">To complete this topic, let’s suppose we want to find <strong>all</strong> lines with the <strong>five</strong> first-names : <strong>jack</strong>, <strong>james</strong>, <strong>jason</strong>, <strong>jules</strong> and <strong>Joe</strong></p>
<p dir="auto">Here are, below, <strong>four</strong> regexes, from the <strong>more restrictive</strong> behaviour to the <strong>less restrictive</strong> behaviour :</p>
<ul>
<li>
<p dir="auto">In regex <strong><code>A</code></strong>, rhe five first-names must be <strong>true</strong> words, in the exact <strong>lower</strong> case</p>
</li>
<li>
<p dir="auto">In regex <strong><code>B</code></strong>, rhe five first-names must be <strong>true</strong> words, <strong>whatever</strong> their case</p>
</li>
<li>
<p dir="auto">In regex <strong><code>C</code></strong>, rhe five first-names may be <strong>glued</strong> in <strong>bigger</strong> words, but with their exact <strong>lower</strong> case</p>
</li>
<li>
<p dir="auto">In regex <strong><code>D</code></strong>, rhe five first-names may be <strong>glued</strong> in <strong>bigger</strong> words, <strong>whatever</strong> their case</p>
</li>
</ul>
<p dir="auto">So :</p>
<ul>
<li>
<p dir="auto">Regex <strong><code>A</code></strong> = <strong><code>(?-is)^(?=.*\bjack\b)(?=.*\bjames\b)(?=.*\bjason\b)(?=.*\bjules\b)(?=.*\bjoe\b).*</code></strong></p>
</li>
<li>
<p dir="auto">Regex <strong><code>B</code></strong> = <strong><code>(?i-s)^(?=.*\bjack\b)(?=.*\bjames\b)(?=.*\bjason\b)(?=.*\bjules\b)(?=.*\bjoe\b).*</code></strong></p>
</li>
<li>
<p dir="auto">Regex <strong><code>C</code></strong> = <strong><code>(?-is)^(?=.*jack)(?=.*james)(?=.*jason)(?=.*jules)(?=.*joe).*</code></strong></p>
</li>
<li>
<p dir="auto">Regex <strong><code>D</code></strong> = <strong><code>(?i-s)^(?=.*jack)(?=.*james)(?=.*jason)(?=.*jules)(?=.*joe).*</code></strong></p>
</li>
</ul>
<p dir="auto"><strong>Notes</strong> :</p>
<ul>
<li>
<p dir="auto">As usual, the <strong>Regular expression</strong> search mode must be <strong>checked</strong> !</p>
</li>
<li>
<p dir="auto">The <strong>initial</strong> modifiers force the search to be <strong>sensitive / insensitive</strong> ( <strong><code>-i / i</code></strong> ) to case, and also means that <strong>dot</strong> matches a <strong>single standard</strong> character only ( <strong><code>-s</code></strong> )</p>
</li>
<li>
<p dir="auto">The <strong><code>^</code></strong> assertion, stands for the location <strong>beginning</strong> of line, where starts the test of the following features ( <strong>look-arounds</strong> )</p>
</li>
<li>
<p dir="auto">Each form <strong><code>(?.*......)</code></strong> is a positive <strong>look-around</strong>, a condition which must be <strong>verified</strong> to get an <strong>overall</strong> match</p>
</li>
<li>
<p dir="auto">If <strong>all</strong> conditions are <strong>true</strong>, the <strong>final</strong> regex is simply <strong><code>^.*</code></strong>, so <strong>all contents</strong> of the line, from its <strong>beginning</strong></p>
</li>
</ul>
<hr />
<p dir="auto">Then, if you copy/paste the <strong>following</strong> lines, in a <strong>new</strong> tab :</p>
<pre><code class="language-diff">01 james
02 jason
03 joe
04 james and jack
05 jason and jules
06 jack, jason and joe
07 peter, joe, jack, james and jules
08 peter, jack, james, jason, jules and joe
09 james, joe, jason, jules, jack and margaret
10 peter, jules, james, jack, jason, joe and margaret
11 joe, jules, jason, james and jack

12 jAMes
13 jASon
14 jOE
15 jAMes and JAck
16 jASon and JUles
17 jACk, jASOn and joe
18 pETer, JOE, jack, jaMEs and JUles
19 pETer, JACk, james, JAson, jULes and joe
20 jAMes, JOE, jason, jULes, jaCK and margaret
21 pETer, JULes, james, Jack, jASon, jOE and margaret
22 jOE, juLES, jason, jAMes and Jack

23 james
24 jason
25 joe
26 james and jack
27 jason and jules
28 jack, jason and joe
29 peter, 12joe34, jack, 56james78 and jules
30 peter, 12jack34, james, 56jason78, jules and joe
31 james, 12joe34, jason, 56jules78, jack and margaret
32 peter, 12jules34, james, 56jack78, jason, joe and margaret
33 joe, 12jules34, jason, 56james78 and jack

34 jAMes
35 jASon
36 jOE
37 jAMes and 12jack34
38 jASon and jules
39 jACk, 12jASOn34 and joe
40 pETer, 12JOE34, jack, 56jaMEs78 and JUles
41 pETer, 12JACk34, james, 56JAson78, jULes and 90joe12
42 jAMes, 12JOE34, jason, 56jULes78, jaCK and margaret
43 pETer, 12JULes34, james, 56Jack78, jASon, 90joe12 and margaret
44 jOE, 12juLES34, jason, 56jAMes78 and 90Jack12
</code></pre>
<p dir="auto">You’ll easily notice that :</p>
<ul>
<li>
<p dir="auto">Regex <strong><code>A</code></strong> matches lines from <strong>8</strong> to <strong>11</strong></p>
</li>
<li>
<p dir="auto">Regex <strong><code>B</code></strong> matches lines from <strong>8</strong> to <strong>11</strong> and from <strong>19</strong> to <strong>22</strong></p>
</li>
<li>
<p dir="auto">Regex <strong><code>C</code></strong> matches lines from <strong>8</strong> to <strong>11</strong> and from <strong>30</strong> to <strong>33</strong></p>
</li>
<li>
<p dir="auto">Regex <strong><code>D</code></strong> matches lines from <strong>8</strong> to <strong>11</strong>, from <strong>19</strong> to <strong>22</strong>, from <strong>30</strong> to <strong>33</strong> and from <strong>41</strong> to <strong>44</strong></p>
</li>
</ul>
<hr />
<p dir="auto">Now, from an <strong>already saved</strong> file, once you’ve got the results, in the <strong>Find Result</strong> panel, <strong>after</strong> clicking on the <strong>Find All in Current Document</strong> button, using one of regexes, <strong>above</strong>, you may, also, search for each <strong>individual</strong> first-name :</p>
<ul>
<li>
<p dir="auto">Right-click in the <strong>Find result</strong> panel</p>
</li>
<li>
<p dir="auto">Select the <strong>Find in this finder…</strong> option</p>
</li>
</ul>
<p dir="auto">Now, in the new <strong>Find in finder</strong> dialog :</p>
<ul>
<li>
<p dir="auto">Type a first-name, for instance <strong><code>jack</code></strong>, in the <strong>Find what:</strong> zone</p>
</li>
<li>
<p dir="auto">Check the <strong>Search only on found lines</strong> option</p>
</li>
<li>
<p dir="auto"><strong>Uncheck</strong> the <strong>two</strong> options <strong>Match whole word only</strong> and <strong>Match case</strong></p>
</li>
<li>
<p dir="auto">Select, if necessary, the <strong>Normal</strong> search mode</p>
</li>
<li>
<p dir="auto">Click on the <strong>Find all</strong> button</p>
</li>
</ul>
<p dir="auto">=&gt; A new <strong>Find resul</strong> tab is created and displays <strong>any</strong> occurrence of the string <strong>jack</strong>, found in the lines of the <strong>Find result</strong> panel, only !</p>
<ul>
<li><strong>Repeat</strong> these steps, changing for an <strong>other</strong> first-name, to get 5 <strong>Find resul</strong> tabs, all using the <strong>Line Filter Mode</strong> of search !</li>
</ul>
<hr />
<p dir="auto"><strong>IMPORTANT</strong> : If the <strong>Find result</strong> panel contains results, from a <strong>non-saved</strong> file ( with <strong><code>new #</code></strong> name ), the <strong>context</strong> option <strong>Find in this filder…</strong> does <strong>NOT</strong> seem to work ! I’ll add a post to @don-ho, to that purpose, very <strong>soon</strong> !</p>
<p dir="auto">Best Regards,</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/26351</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/26351</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Sun, 20 Aug 2017 22:48:12 GMT</pubDate></item><item><title><![CDATA[Reply to Find all lines that contain specific strings on Thu, 17 Aug 2017 19:54:37 GMT]]></title><description><![CDATA[<p dir="auto">Thank you very much for great and awesome help<br />
Best Regards</p>
]]></description><link>https://community.notepad-plus-plus.org/post/26311</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/26311</guid><dc:creator><![CDATA[Yasser Khalil]]></dc:creator><pubDate>Thu, 17 Aug 2017 19:54:37 GMT</pubDate></item><item><title><![CDATA[Reply to Find all lines that contain specific strings on Thu, 17 Aug 2017 19:15:45 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/yasser-khalil" aria-label="Profile: Yasser-Khalil">@<bdi>Yasser-Khalil</bdi></a> said:</p>
<blockquote>
<p dir="auto">search four or five strings</p>
</blockquote>
<p dir="auto">Not so hard, one of the hits in the “here” link above explains it, but here is the basics of <em><strong>multiple-words-on-a-line-in-any-order</strong></em> searching:</p>
<ul>
<li>3 words:  <code>(?-s)(?=.*word1)(?=.*word2)(?=.*word3).*</code></li>
<li>4 words:  <code>(?-s)(?=.*word1)(?=.*word2)(?=.*word3)(?=.*word4).*</code></li>
<li>5 words:  <code>(?-s)(?=.*word1)(?=.*word2)(?=.*word3)(?=.*word4)(?=.*word5).*</code></li>
<li>etc.</li>
</ul>
<p dir="auto">You can add <code>\b</code> before and after each word in your search if you truly want that exact word…and not words embedded in others…for example <code>\btest\b</code> will match <code>test</code> but not <code>tester</code>, <code>testing</code>, <code>stoutest</code>, etc.</p>
<p dir="auto">If this (or <em>ANY</em> posting on the <strong>Notepad++ Community</strong> site) is useful, don’t reply with a <em>“thanks”</em>, simply <strong>up-vote</strong> ( click the <code>^</code> in the <code>^ 0 v</code> area on the right ).</p>
]]></description><link>https://community.notepad-plus-plus.org/post/26310</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/26310</guid><dc:creator><![CDATA[Scott Sumner]]></dc:creator><pubDate>Thu, 17 Aug 2017 19:15:45 GMT</pubDate></item><item><title><![CDATA[Reply to Find all lines that contain specific strings on Thu, 17 Aug 2017 19:04:40 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/scott-sumner" aria-label="Profile: Scott-Sumner">@<bdi>Scott-Sumner</bdi></a> said:</p>
<blockquote>
<p dir="auto">(?-s)(?i)pleas.*help|help.*pleas</p>
</blockquote>
<p dir="auto">Thank you very much scott for this great help<br />
But what if I need to search four or five strings … that would be confusing!!</p>
]]></description><link>https://community.notepad-plus-plus.org/post/26309</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/26309</guid><dc:creator><![CDATA[Yasser Khalil]]></dc:creator><pubDate>Thu, 17 Aug 2017 19:04:40 GMT</pubDate></item><item><title><![CDATA[Reply to Find all lines that contain specific strings on Thu, 17 Aug 2017 18:34:00 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/yasser-khalil" aria-label="Profile: Yasser-Khalil">@<bdi>Yasser-Khalil</bdi></a></p>
<p dir="auto">A good way to get an answer would be to click <a href="http://lmgtfy.com/?q=find+two+words+on+a+line+in+either+order" title="click me and all will be revealed" rel="nofollow ugc">here</a>, but…</p>
<p dir="auto">…you can do it by searching this way:</p>
<ul>
<li><code>Find-what</code> box:  <code>(?-s)(?i)pleas.*help|help.*pleas</code></li>
<li><code>Search mode</code>:  Regular expression</li>
<li>Press <code>Find All in Current Document</code> button</li>
</ul>
<p dir="auto">At that point your results will be shown in the <code>Find result</code> panel.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/26308</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/26308</guid><dc:creator><![CDATA[Scott Sumner]]></dc:creator><pubDate>Thu, 17 Aug 2017 18:34:00 GMT</pubDate></item></channel></rss>