<?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[Search Just Within Provided Line Number]]></title><description><![CDATA[<p dir="auto">I need to be search line number 4 for the number 2.  I need to perform this search on a directory of text files.  Is this possible?</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/25403/search-just-within-provided-line-number</link><generator>RSS for Node</generator><lastBuildDate>Sat, 18 Jul 2026 00:22:53 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/25403.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 23 Jan 2024 19:56:01 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Search Just Within Provided Line Number on Wed, 24 Jan 2024 03:25:09 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/guy038" aria-label="Profile: guy038">@<bdi>guy038</bdi></a> said in <a href="/post/92310">Search Just Within Provided Line Number</a>:</p>
<blockquote>
<p dir="auto">I don’t understand because, in my post, I do NOT speak about deleting the 2 digit, at any moment ?</p>
</blockquote>
<p dir="auto">Ah…you’re right.  I supposed I was confused because when you said:</p>
<blockquote>
<p dir="auto">Leave the Replace with: zone Empty</p>
</blockquote>
<p dir="auto">It appeared to me like this was setting up a replace-with-nothing aka delete operation!</p>
]]></description><link>https://community.notepad-plus-plus.org/post/92312</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/92312</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Wed, 24 Jan 2024 03:25:09 GMT</pubDate></item><item><title><![CDATA[Reply to Search Just Within Provided Line Number on Wed, 24 Jan 2024 02:55:34 GMT]]></title><description><![CDATA[<p dir="auto">Hello, <a class="plugin-mentions-user plugin-mentions-a" href="/user/scott-daniels" aria-label="Profile: scott-daniels">@<bdi>scott-daniels</bdi></a>, <a class="plugin-mentions-user plugin-mentions-a" href="/user/terry-r" aria-label="Profile: terry-r">@<bdi>terry-r</bdi></a>, <a class="plugin-mentions-user plugin-mentions-a" href="/user/coises" aria-label="Profile: coises">@<bdi>coises</bdi></a> <a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: alan-kilborn">@<bdi>alan-kilborn</bdi></a>, <a class="plugin-mentions-user plugin-mentions-a" href="/user/peterjones" aria-label="Profile: peterjones">@<bdi>peterjones</bdi></a> and <strong>All</strong>,</p>
<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>, you said :</p>
<blockquote>
<ul>
<li>Guy did too much (OP didn’t mention deleting the matching text, only finding it)</li>
</ul>
</blockquote>
<p dir="auto">I don’t understand because, in my post, I do <em>NOT</em> speak about deleting the <strong><code>2</code></strong> digit, at any moment ?</p>
<hr />
<p dir="auto">Now, about the <a class="plugin-mentions-user plugin-mentions-a" href="/user/coises" aria-label="Profile: coises">@<bdi>coises</bdi></a> syntax <strong><code>\A([^\r\n]*+\R){3}[^\r\n]*\K2</code></strong>, with an <strong>atomic</strong> ( <strong>possessive</strong> ) syntax, I don’t see the <strong>bonus</strong> to use it !</p>
<p dir="auto">Indeed, it necessarily needs to get some <strong><code>EOL</code></strong> chars <strong>after</strong> the <strong>possible standard</strong> chars <strong><code>[\r\n]*</code></strong>. Thus, it will grasp <strong>all</strong> standard chars, even <strong>zero</strong>, followed with <strong><code>EOL</code></strong> char(s), in <strong>all</strong> cases !</p>
<p dir="auto">And note that I use the <strong><code>(?-s)</code></strong> <strong>modifier</strong> which means that the <strong><code>.</code></strong> regex char is <strong>identical</strong> to <strong><code>[^\r\n\f]</code></strong>, anyway !</p>
<hr />
<p dir="auto">But, I must admit that the <strong>second</strong> <a class="plugin-mentions-user plugin-mentions-a" href="/user/coises" aria-label="Profile: coises">@<bdi>coises</bdi></a>’s solution is more <strong>accurate</strong>, if the OP needs to get the number <strong><code>2</code></strong>, <strong>only</strong></p>
<p dir="auto">Thus, we end up, with this search regex :</p>
<p dir="auto"><strong><code>(?-s)\A(?:.*\R){3}.*?\K(?&lt;!\d)2(?!\d)</code></strong></p>
<p dir="auto">Best Regards,</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/92310</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/92310</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Wed, 24 Jan 2024 02:55:34 GMT</pubDate></item><item><title><![CDATA[Reply to Search Just Within Provided Line Number on Tue, 23 Jan 2024 23:25:34 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/peterjones" aria-label="Profile: PeterJones">@<bdi>PeterJones</bdi></a> said in <a href="/post/92304">Search Just Within Provided Line Number</a>:</p>
<blockquote>
<p dir="auto">Your regex will match the file below, even though the fourth line doesn’t have a 2 in it anywhere – lines 2-5 fit the pattern you defined.</p>
</blockquote>
<p dir="auto">Thanks, I now stand corrected. Somehow with my meagre testing on a small file I neglected to include another occurrence further down the file. Of course that shouldn’t have affected my decision as I knew the regex completes as many iterations as necessary to include the “whole file”, but there was a snafu in my solution. Yes using the <code>\A</code> is necessary to JUST look at the nth line ONLY.</p>
<p dir="auto">Thanks<br />
Terry</p>
<p dir="auto">PS <a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: Alan-Kilborn">@<bdi>Alan-Kilborn</bdi></a> I DID read your info, but somehow that didn’t allow me to make the connection and Peter’s example is what it took to get me over the line. I guess today just isn’t my day, there’s always tomorrow!</p>
]]></description><link>https://community.notepad-plus-plus.org/post/92309</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/92309</guid><dc:creator><![CDATA[Terry R]]></dc:creator><pubDate>Tue, 23 Jan 2024 23:25:34 GMT</pubDate></item><item><title><![CDATA[Reply to Search Just Within Provided Line Number on Tue, 23 Jan 2024 22:22:19 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">Oh, you’re right… I missed the <code>[^\r\n]*</code> when I was reading it (and didn’t try his before my post).</p>
<p dir="auto">So yes, I just confirmed <a class="plugin-mentions-user plugin-mentions-a" href="/user/coises" aria-label="Profile: Coises">@<bdi>Coises</bdi></a>’ suggestion works on my test data, too.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/92306</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/92306</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Tue, 23 Jan 2024 22:22:19 GMT</pubDate></item><item><title><![CDATA[Reply to Search Just Within Provided Line Number on Tue, 23 Jan 2024 22:01:14 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/peterjones" aria-label="Profile: PeterJones">@<bdi>PeterJones</bdi></a> said in <a href="/post/92304">Search Just Within Provided Line Number</a>:</p>
<blockquote>
<p dir="auto">I am not sure <a class="plugin-mentions-user plugin-mentions-a" href="/user/coises" aria-label="Profile: Coises">@<bdi>Coises</bdi></a> is right, either, because his assumes the fourth line starts with a 2</p>
</blockquote>
<p dir="auto">Coises uses <code>[^\r\n]*\K2</code> which would start trying to match at the beginning of line 4 (from the earlier stuff in his regex).  It appears to read (starting there) as "match any non-line-ending chars zero-or-more times followed by a <code>2</code> – seems to fit the bill.  I’m away from my PC right now, so I can’t try it, though.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/92305</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/92305</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Tue, 23 Jan 2024 22:01:14 GMT</pubDate></item><item><title><![CDATA[Reply to Search Just Within Provided Line Number on Tue, 23 Jan 2024 21:54:41 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/terry-r" aria-label="Profile: Terry-R">@<bdi>Terry-R</bdi></a> ,</p>
<p dir="auto">As with all regex, if it doesn’t match at the start of the search, it keeps going to the end, checking if each position matches.  Your regex will match the file below, even though the fourth line doesn’t have a 2 in it anywhere – lines 2-5 fit the pattern you defined.</p>
<pre><code>one
two
three
four
five has 2
six
</code></pre>
<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">I am not sure <a class="plugin-mentions-user plugin-mentions-a" href="/user/coises" aria-label="Profile: Coises">@<bdi>Coises</bdi></a> is right, either, because his assumes the fourth line <em>starts</em> with a 2, whereas the phrasing of the OP implies it might be anywhere on line 4.  (And <a class="plugin-mentions-user plugin-mentions-a" href="/user/guy038" aria-label="Profile: guy038">@<bdi>guy038</bdi></a> replicated that understanding.)</p>
<p dir="auto"><code>(?-s)\A(.*\R){3}\K(.*2.*)</code> is my suggestion – I also removed the trailing <code>\R</code>, otherwise a 4-line file missing final newline wouldn’t be found.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/92304</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/92304</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Tue, 23 Jan 2024 21:54:41 GMT</pubDate></item><item><title><![CDATA[Reply to Search Just Within Provided Line Number on Tue, 23 Jan 2024 21:44:43 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 in <a href="/post/92301">Search Just Within Provided Line Number</a>:</p>
<blockquote>
<p dir="auto">Yes, but nothing prevents your regex from starting a match later in the file (if one/more happens to exist).</p>
</blockquote>
<p dir="auto">Isn’t that a contradiction?</p>
<p dir="auto">First you agree that each search in “Find in Files” commences at the start of a file. Then you suggest somehow a regex can “slip” to another possible occurrence. I don’t see how. Even if the search is repeated it will still find the same occurrence as the previous search.</p>
<p dir="auto">Terry</p>
<p dir="auto">PS maybe if there is some further debate we should start a new thread rather than cloud the OP’s judgement on other things.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/92303</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/92303</guid><dc:creator><![CDATA[Terry R]]></dc:creator><pubDate>Tue, 23 Jan 2024 21:44:43 GMT</pubDate></item><item><title><![CDATA[Reply to Search Just Within Provided Line Number on Tue, 23 Jan 2024 21:40:52 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/terry-r" aria-label="Profile: Terry-R">@<bdi>Terry-R</bdi></a> said in <a href="/post/92300">Search Just Within Provided Line Number</a>:</p>
<blockquote>
<p dir="auto">doesn’t each Find in Files search always start at the beginning</p>
</blockquote>
<p dir="auto">Yes, but nothing prevents your regex from starting a match <em>later</em> in the file (if one/more happens to exist).  The <code>\A</code> will do this.</p>
<p dir="auto">Of course, since OP is apparently just visually inspecting results, he could ignore any matches that aren’t near the top-of-file.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/92301</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/92301</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Tue, 23 Jan 2024 21:40:52 GMT</pubDate></item><item><title><![CDATA[Reply to Search Just Within Provided Line Number on Tue, 23 Jan 2024 21:32:19 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 in <a href="/post/92299">Search Just Within Provided Line Number</a>:</p>
<blockquote>
<p dir="auto">Terry didn’t use \A to keep the search anchored to the start of file</p>
</blockquote>
<p dir="auto">Unless I’m mistaken, doesn’t each Find in Files search always start at the beginning, thus making the \A redundant. Of course keeping it in just means being consistent with regex making, but since it’s used very in-often we hardly ever see it in regexes even for opened documents.</p>
<p dir="auto">Terry</p>
]]></description><link>https://community.notepad-plus-plus.org/post/92300</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/92300</guid><dc:creator><![CDATA[Terry R]]></dc:creator><pubDate>Tue, 23 Jan 2024 21:32:19 GMT</pubDate></item><item><title><![CDATA[Reply to Search Just Within Provided Line Number on Tue, 23 Jan 2024 21:38:03 GMT]]></title><description><![CDATA[<p dir="auto">I think <a class="plugin-mentions-user plugin-mentions-a" href="/user/coises" aria-label="Profile: Coises">@<bdi>Coises</bdi></a> 's answer is best here:</p>
<ul>
<li>Terry didn’t use <code>\A</code> to keep the search anchored to the start of file</li>
<li>Guy did too much (OP didn’t mention <em>deleting</em> the matching text, only <em>finding</em> it)</li>
<li>Coises gets bonus points for using the possessive form</li>
</ul>
]]></description><link>https://community.notepad-plus-plus.org/post/92299</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/92299</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Tue, 23 Jan 2024 21:38:03 GMT</pubDate></item><item><title><![CDATA[Reply to Search Just Within Provided Line Number on Tue, 23 Jan 2024 21:05:59 GMT]]></title><description><![CDATA[<p dir="auto">Hello, <a class="plugin-mentions-user plugin-mentions-a" href="/user/scott-daniels" aria-label="Profile: scott-daniels">@<bdi>scott-daniels</bdi></a>, <a class="plugin-mentions-user plugin-mentions-a" href="/user/terry-r" aria-label="Profile: terry-r">@<bdi>terry-r</bdi></a>, <a class="plugin-mentions-user plugin-mentions-a" href="/user/coises" aria-label="Profile: coises">@<bdi>coises</bdi></a> and <strong>All</strong>,</p>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/scott-daniels" aria-label="Profile: scott-daniels">@<bdi>scott-daniels</bdi></a>, I realize that other people have <strong>already</strong> beaten me to it !!</p>
<hr />
<p dir="auto">Here is how I understand your question :</p>
<ul>
<li>
<p dir="auto">For each <strong>text</strong> file in a <strong>specific</strong> folder :</p>
<ul>
<li>
<p dir="auto">Don(t care about the <strong>first three</strong> lines of <strong>each</strong> file</p>
</li>
<li>
<p dir="auto">And looks for, at least, <strong>one</strong> occurrence of the string <strong><code>2</code></strong> in the <strong>fourth</strong> line of <strong>each</strong> file</p>
</li>
</ul>
</li>
</ul>
<p dir="auto">Am I right regarding this assumption ?</p>
<hr />
<p dir="auto">In case of a <strong>positive</strong> answer, here is my solution, similar to their ones :</p>
<ul>
<li>
<p dir="auto">Open the <strong>Find in Files</strong> dialog ( <strong><code>Ctrl + Shift + F</code></strong> )</p>
</li>
<li>
<p dir="auto"><strong>Untick</strong> all <strong>box</strong> options</p>
</li>
<li>
<p dir="auto">Fill in the string <strong><code>(?-s)\A(.*\R){3}.*?\K2</code></strong> in the <strong>Find what:</strong> zone</p>
</li>
<li>
<p dir="auto">Leave the <strong>Replace with:</strong> zone <strong><code>Empty</code></strong></p>
</li>
<li>
<p dir="auto">Enter <strong><code>*.txt</code></strong> in the <strong>Filters :</strong> zone</p>
</li>
<li>
<p dir="auto">Enter <strong>full pathname</strong> of your directory <strong><code>name</code></strong> in the <strong>Directory :</strong> zone</p>
</li>
<li>
<p dir="auto">Select the <strong><code>Regular expression</code></strong> search <strong>mode</strong></p>
</li>
<li>
<p dir="auto">Click <strong>once</strong> on the <strong><code>Find All</code></strong> button</p>
</li>
<li>
<p dir="auto"><strong>Wait</strong> till the <strong><code>Search results</code></strong> window is displayed !</p>
</li>
</ul>
<p dir="auto">Best regards</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/92298</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/92298</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Tue, 23 Jan 2024 21:05:59 GMT</pubDate></item><item><title><![CDATA[Reply to Search Just Within Provided Line Number on Tue, 23 Jan 2024 20:35:23 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/scott-daniels" aria-label="Profile: Scott-Daniels">@<bdi>Scott-Daniels</bdi></a> said in <a href="/post/92294">Search Just Within Provided Line Number</a>:</p>
<blockquote>
<p dir="auto">I need to be search line number 4 for the number 2.  I need to perform this search on a directory of text files.  Is this possible?</p>
</blockquote>
<p dir="auto"><strong>Search</strong> | <strong>Find in Files…</strong> from the main menu; then enter:</p>
<p dir="auto"><strong>Find what: <code>\A([^\r\n]*+\R){3}[^\r\n]*\K2</code></strong><br />
<strong>Search Mode: Regular expression</strong><br />
<strong>Filters: <code>*.*</code></strong> <em>or</em> <strong><code>*.txt</code></strong><br />
<strong>Directory:</strong> <em>set as appropriate using</em> <strong>…</strong> <em>button</em></p>
<p dir="auto">and click <strong>Find All</strong>.</p>
<p dir="auto">Edit to add: Rereading, I see that you said “the number 2” and not “the digit 2.” If you meant that you specifically need to find <strong>2</strong> but not <strong>20</strong> or <strong>12</strong>, then change the expression to:</p>
<p dir="auto"><strong>Find what: <code>\A([^\r\n]*+\R){3}[^\r\n]*\K(?&lt;!\d)2(?!\d)</code></strong></p>
]]></description><link>https://community.notepad-plus-plus.org/post/92297</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/92297</guid><dc:creator><![CDATA[Coises]]></dc:creator><pubDate>Tue, 23 Jan 2024 20:35:23 GMT</pubDate></item><item><title><![CDATA[Reply to Search Just Within Provided Line Number on Tue, 23 Jan 2024 20:28:51 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/scott-daniels" aria-label="Profile: Scott-Daniels">@<bdi>Scott-Daniels</bdi></a> said in <a href="/post/92294">Search Just Within Provided Line Number</a>:</p>
<blockquote>
<p dir="auto">Is this possible?</p>
</blockquote>
<p dir="auto">Certainly is. To work you need to use the “Find in Files” function, have the search mode set to Regular Expression and the following red text in the Find What field:<code>(?-s)^(.*\R){3}\K(.*2.*\R)</code></p>
<p dir="auto">You would then fill in the remaining fields as necessary to locate the folder containing the files and any other filtering necessary to only test the files you want within that folder (say you have TXT and BIN files), you would use <code>*.TXT</code> in the filters field.</p>
<p dir="auto">Click on the Find All, and the search panel will appear with the results of which files meet that criteria.</p>
<p dir="auto">Have a go, and if issues come back with more questions.</p>
<p dir="auto">Terry</p>
]]></description><link>https://community.notepad-plus-plus.org/post/92296</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/92296</guid><dc:creator><![CDATA[Terry R]]></dc:creator><pubDate>Tue, 23 Jan 2024 20:28:51 GMT</pubDate></item></channel></rss>