<?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 text and replace at the top of file]]></title><description><![CDATA[<p dir="auto">Hi,<br />
Is there a way to find text, in this case &lt;!DOCTYPE HTML&gt; in all JSP files and replace it at the top of the file. Like, cut and paste at the top. If this is not possible, I would like to find all files which doesn’t have &lt;!DOCTYPE HTML&gt; at the beginning.</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/18915/find-text-and-replace-at-the-top-of-file</link><generator>RSS for Node</generator><lastBuildDate>Sat, 05 Sep 2026 17:29:35 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/18915.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 14 Feb 2020 18:15:44 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Find text and replace at the top of file on Fri, 14 Feb 2020 21:40:29 GMT]]></title><description><![CDATA[<p dir="auto">Thanks <a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: Alan-Kilborn">@<bdi>Alan-Kilborn</bdi></a>  and <a class="plugin-mentions-user plugin-mentions-a" href="/user/guy038" aria-label="Profile: guy038">@<bdi>guy038</bdi></a> . Both of them worked what I was looking for. I’m still new to regular expressions, but I will try to dig in more on both of your solutions.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/50670</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/50670</guid><dc:creator><![CDATA[Srirup Das]]></dc:creator><pubDate>Fri, 14 Feb 2020 21:40:29 GMT</pubDate></item><item><title><![CDATA[Reply to Find text and replace at the top of file on Fri, 14 Feb 2020 21:11:25 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></p>
<p dir="auto">True enough, although these discussions tend to evolve to “build up a regex” by just adding on to what was said last.  That’s what I did in this case.</p>
<p dir="auto">Throwing most of it out might have been more confusing to the OP.</p>
<p dir="auto">But I’d still like the OP to answer my question as well as now a second question:  Why the <code>+</code> in <a class="plugin-mentions-user plugin-mentions-a" href="/user/guy038" aria-label="Profile: guy038">@<bdi>guy038</bdi></a> 's regex is the absolute key to the whole thing!</p>
]]></description><link>https://community.notepad-plus-plus.org/post/50668</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/50668</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Fri, 14 Feb 2020 21:11:25 GMT</pubDate></item><item><title><![CDATA[Reply to Find text and replace at the top of file on Fri, 14 Feb 2020 20:53:58 GMT]]></title><description><![CDATA[<p dir="auto">Hello, <a class="plugin-mentions-user plugin-mentions-a" href="/user/srirup-das" aria-label="Profile: srirup-das">@<bdi>srirup-das</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">I do <strong>not</strong> get much credit for intervening at the <strong>end</strong> of the discussion to announce that the <strong>negative look-ahead</strong> <strong><code>(?!&lt;!DOCTYPE HTML&gt;)</code></strong> sems <strong>useless</strong>, in the <strong>last</strong> version of the regex !</p>
<p dir="auto">Indeed, this <strong>shorter</strong> syntax <strong><code>(?&lt;!\x0A)^(?s).+&lt;!DOCTYPE HTML&gt;</code></strong> is enough to get the job done ;-)) As the <strong>former</strong> regex, it <strong>even</strong> detects files whose the <strong>first</strong> line is, let’s say, as <strong><code>ABC&lt;!DOCTYPE HTML&gt;</code></strong>  ( so, not exactly at the <strong>very beginning</strong> of current file ) !</p>
<p dir="auto">Best Regards,</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/50667</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/50667</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Fri, 14 Feb 2020 20:53:58 GMT</pubDate></item><item><title><![CDATA[Reply to Find text and replace at the top of file on Fri, 14 Feb 2020 19:54:15 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/srirup-das" aria-label="Profile: Srirup-Das">@<bdi>Srirup-Das</bdi></a></p>
<p dir="auto">Okay, okay, one more freebie, but after that unless I start charging your for consulting, the others here (and really, me, too) are gonna get all over me/us.  :-)</p>
<p dir="auto"><code>(?&lt;!\x0A)^(?!&lt;!DOCTYPE HTML&gt;)(?s).*?&lt;!DOCTYPE HTML&gt;</code></p>
<p dir="auto">NOW, What you owe ME is to interpret this and reply back with how it works (assuming it does)!</p>
]]></description><link>https://community.notepad-plus-plus.org/post/50666</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/50666</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Fri, 14 Feb 2020 19:54:15 GMT</pubDate></item><item><title><![CDATA[Reply to Find text and replace at the top of file on Fri, 14 Feb 2020 19:47:39 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> One more thing I found is (?&lt;!\x0A)^(?!&lt;!DOCTYPE HTML&gt;) is listing down the files which doesn’t have &lt;!DOCTYPE HTML&gt; at all in the file. I don’t need those files. I need only the files which contains &lt;!DOCTYPE HTML&gt; but not at the top.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/50665</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/50665</guid><dc:creator><![CDATA[Srirup Das]]></dc:creator><pubDate>Fri, 14 Feb 2020 19:47:39 GMT</pubDate></item><item><title><![CDATA[Reply to Find text and replace at the top of file on Fri, 14 Feb 2020 19:20:22 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> Seems like (?&lt;!\x0A)^(?!&lt;!DOCTYPE HTML&gt;) is working. Thanks for your help.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/50663</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/50663</guid><dc:creator><![CDATA[Srirup Das]]></dc:creator><pubDate>Fri, 14 Feb 2020 19:20:22 GMT</pubDate></item><item><title><![CDATA[Reply to Find text and replace at the top of file on Fri, 14 Feb 2020 18:33:19 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/srirup-das" aria-label="Profile: Srirup-Das">@<bdi>Srirup-Das</bdi></a></p>
<p dir="auto">For that, I’d be tempted to try <code>(?&lt;!\x0A)^(?!&lt;!DOCTYPE HTML&gt;).</code></p>
<p dir="auto">Note that this one matches only a single character when the special string is NOT in a file.</p>
<p dir="auto">But my eyes are swimming…the usage of this sequence <code>?&lt;!</code> versus this one <code>?!&lt;!</code> meaning two totally different and unrelated things. :-)</p>
]]></description><link>https://community.notepad-plus-plus.org/post/50660</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/50660</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Fri, 14 Feb 2020 18:33:19 GMT</pubDate></item><item><title><![CDATA[Reply to Find text and replace at the top of file on Fri, 14 Feb 2020 18:28:18 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> Thanks for your response. What would be the regular expression to find in files which doesn’t have  &lt;!DOCTYPE HTML&gt; at the top of the file.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/50659</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/50659</guid><dc:creator><![CDATA[Srirup Das]]></dc:creator><pubDate>Fri, 14 Feb 2020 18:28:18 GMT</pubDate></item><item><title><![CDATA[Reply to Find text and replace at the top of file on Fri, 14 Feb 2020 18:23:50 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/srirup-das" aria-label="Profile: Srirup-Das">@<bdi>Srirup-Das</bdi></a></p>
<p dir="auto">A technique for matching your data only at top-of-file would be searching for this regular expression:  <code>(?&lt;!\x0A)^&lt;!DOCTYPE HTML&gt;</code></p>
<p dir="auto">I had bookmarked the origin of this technique, and it is <a href="https://community.notepad-plus-plus.org/topic/16104/how-to-find-and-highlight-a-specific-occurance-of-a-symbol/">here</a> if you want to read more.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/50656</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/50656</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Fri, 14 Feb 2020 18:23:50 GMT</pubDate></item></channel></rss>