<?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[Deleting a group of characters in lines with same beginning and ending, but different in between (re-post)]]></title><description><![CDATA[<p dir="auto">Fellow Notepad++ Users,<br />
Could you please help me the the following search-and-replace problem I am having?<br />
I want to delete the [/b] in lines with the same beginning and ending, but different characters in between, like these:</p>
<p dir="auto">Here is the data I currently have (“before” data):</p>
<pre><code>[m3][c #0A5D00]▸[i] You’d get up early[/i][/b][/c][/m3]
[m3][c #0A5D00]▸[i] We prefer cheese[/i][/b][/c][/m3]
[m3][c #0A5D55]▸[b][i] charity fund[/i][/b][/c][/m3]
[m3][c #0A5D00]▸[i] They never came[/i][/b][/c][/m3]
[m3][c #0A5D55]▸[b][i] board of charity[/i][/b][/c][/m3]

</code></pre>
<p dir="auto">Here is how I would like that data to look (“after” data):</p>
<pre><code>[m3][c #0A5D00]▸[i] You’d get up early[/i][/c][/m3]
[m3][c #0A5D00]▸[i] We prefer cheese[/i][/c][/m3]
[m3][c #0A5D55]▸[b][i] charity fund[/i][/b][/c][/m3]
[m3][c #0A5D00]▸[i] They never came[/i][/c][/m3]
[m3][c #0A5D55]▸[b][i] board of charity[/i][/b][/c][/m3]
</code></pre>
<p dir="auto">To accomplish this, I have tried using the following Find/Replace expressions and settings<br />
•	Find What = <code>[m3][c #0A5D00]▸[i]*[/i][/b][/c][/m3]</code><br />
•	Replace With = <code>[m3][c #0A5D00]▸[i]*[/i][/c][/m3]</code><br />
•	Search Mode = all the three, one after another (REGULAR EXPRESSION, then NORMAL, then EXTENDED)<br />
•	Dot Matches Newline = NOT CHECKED<br />
I tried the Find What function first, but it didn’t work, and I’m not sure why.<br />
Could you please help me understand what went wrong and help me find the solution?<br />
Thank you.</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/22042/deleting-a-group-of-characters-in-lines-with-same-beginning-and-ending-but-different-in-between-re-post</link><generator>RSS for Node</generator><lastBuildDate>Sun, 07 Jun 2026 08:33:45 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/22042.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 24 Oct 2021 04:49:03 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Deleting a group of characters in lines with same beginning and ending, but different in between (re-post) on Mon, 25 Oct 2021 09:30:44 GMT]]></title><description><![CDATA[<p dir="auto">I’ve been able to get the job done, using the suggestions by guy038, which seems the simplest for me.<br />
(<br />
SEARCH (?-si)^(.+#0A5D00.+)[/b]</p>
<p dir="auto">REPLACE $1</p>
<p dir="auto">… )</p>
<p dir="auto">Anyhow, thank you both for taking the trouble to help.<br />
With best wishes</p>
]]></description><link>https://community.notepad-plus-plus.org/post/70880</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/70880</guid><dc:creator><![CDATA[Polar Bear]]></dc:creator><pubDate>Mon, 25 Oct 2021 09:30:44 GMT</pubDate></item><item><title><![CDATA[Reply to Deleting a group of characters in lines with same beginning and ending, but different in between (re-post) on Sun, 24 Oct 2021 12:19:56 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/70853">Deleting a group of characters in lines with same beginning and ending, but different in between (re-post)</a>:</p>
<blockquote>
<p dir="auto">“How to delete the [/b] string in any line which does not contain a [b] string before”</p>
</blockquote>
<p dir="auto">I am just realizing, late in the game, his spec could have been very concisely stated, “delete [/b] from all <em>uncharitable</em> lines”! (You may not give up until you find the pun.)</p>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/polar-bear" aria-label="Profile: polar-bear">@<bdi>polar-bear</bdi></a> Note that the two solutions presented to you differ in another interesting way:</p>
<p dir="auto">#1 satisfies a “before-text” precondition, then matches only the “to-remove-text” which is replaced with nil; it “takes away”</p>
<p dir="auto">#2 both “before-text” and “to-remove-text” are matched but the “before-text” is stored in its own named basket, and that is what replaces the total match; it “replaces a whole with a part”.</p>
<p dir="auto">This gives you an idea of the power and flexibility of this rather unpretty programming language.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/70855</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/70855</guid><dc:creator><![CDATA[Neil Schipper]]></dc:creator><pubDate>Sun, 24 Oct 2021 12:19:56 GMT</pubDate></item><item><title><![CDATA[Reply to Deleting a group of characters in lines with same beginning and ending, but different in between (re-post) on Sun, 24 Oct 2021 11:38:50 GMT]]></title><description><![CDATA[<p dir="auto">Hi, <a class="plugin-mentions-user plugin-mentions-a" href="/user/polar-bear" aria-label="Profile: polar-bear">@<bdi>polar-bear</bdi></a>, <a class="plugin-mentions-user plugin-mentions-a" href="/user/neil-schipper" aria-label="Profile: neil-schipper">@<bdi>neil-schipper</bdi></a> and <strong>All</strong>,</p>
<p dir="auto"><strong>Neil</strong>, you’re right about the <strong>general</strong> behavior of my regex. Yours is more <strong>robust</strong>, of course.</p>
<p dir="auto">However the <strong>example</strong> provided by the OP is really <strong>minimalist</strong> : we don’t about about possible other <strong><code>#0A....</code></strong> strings, different from <strong><code>#0A5D00</code></strong> and <strong><code>#0A5D55</code></strong>. We don’t know about the <strong>context</strong> of these lines and so on…</p>
<p dir="auto">So, I just rely on the <strong>changes</strong> of the <strong><code>#A0....</code></strong> part !</p>
<hr />
<p dir="auto">Now, if <a class="plugin-mentions-user plugin-mentions-a" href="/user/polar-bear" aria-label="Profile: polar-bear">@<bdi>polar-bear</bdi></a> want to search, for example, for the strings <strong><code>#0A5D00</code></strong>, <strong><code>#0A5C00</code></strong>, <strong><code>#0A5E50</code></strong> and <strong><code>#0A5FFF</code></strong>, <strong>simultaneously</strong>, my regex would become :</p>
<p dir="auto">SEARCH <strong><code>(?-si)^(.+#0A(?:5D00|5C00|5E50|5FFF).+)\\[/b\\]</code></strong></p>
<p dir="auto">REPLACE <strong><code>$1</code></strong></p>
<p dir="auto">BR</p>
<p dir="auto">guy038</p>
<p dir="auto"><strong>P.S.</strong>:</p>
<p dir="auto">Oh, I just saw, in the OP’s example, that the suppression of <strong><code>[/b]</code></strong> must occur <strong>only</strong> in lines which do <strong>not</strong> have the string <strong><code>[b]</code></strong>, before the <strong>random</strong> text. So, may be his challenge could be expressed, in <strong>fluent</strong> language, as :</p>
<p dir="auto">“How to delete the <strong><code>[/b]</code></strong> string in any line which does <strong>not</strong> contain a <strong><code>[b]</code></strong> string before” ???</p>
<p dir="auto">Wait and see !</p>
]]></description><link>https://community.notepad-plus-plus.org/post/70853</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/70853</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Sun, 24 Oct 2021 11:38:50 GMT</pubDate></item><item><title><![CDATA[Reply to Deleting a group of characters in lines with same beginning and ending, but different in between (re-post) on Sun, 24 Oct 2021 09:56:29 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/polar-bear" aria-label="Profile: polar-bear">@<bdi>polar-bear</bdi></a> Note that <a class="plugin-mentions-user plugin-mentions-a" href="/user/guy038" aria-label="Profile: guy038">@<bdi>guy038</bdi></a>’s solution, which does not rely on \K, allows you to do single <em>Replace</em> operations in case you had a need to interactively check each instance before replacing.</p>
<p dir="auto">It’s also very tolerant of unspecified text both before and after <code>#0A5D00</code>, while mine uses more rigid constraints.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/70851</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/70851</guid><dc:creator><![CDATA[Neil Schipper]]></dc:creator><pubDate>Sun, 24 Oct 2021 09:56:29 GMT</pubDate></item><item><title><![CDATA[Reply to Deleting a group of characters in lines with same beginning and ending, but different in between (re-post) on Sun, 24 Oct 2021 09:31:32 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/neil-schipper" aria-label="Profile: Neil-Schipper">@<bdi>Neil-Schipper</bdi></a></p>
<p dir="auto">aaaaaaaaand I forgot to say it’s a regex</p>
<p dir="auto">aaaaaaaaand I forgot to say: you may click <em>Find</em> to satisfy yourself it’s matching the text to remove; when you want to apply the changes to the whole file, use <em>Replace All</em>. This is a class of regex for which the a single <em>Replace</em> operation does not work, for reasons I don’t understand.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/70850</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/70850</guid><dc:creator><![CDATA[Neil Schipper]]></dc:creator><pubDate>Sun, 24 Oct 2021 09:31:32 GMT</pubDate></item><item><title><![CDATA[Reply to Deleting a group of characters in lines with same beginning and ending, but different in between (re-post) on Sun, 24 Oct 2021 09:31:51 GMT]]></title><description><![CDATA[<p dir="auto">Hello, <a class="plugin-mentions-user plugin-mentions-a" href="/user/polar-bear" aria-label="Profile: polar-bear">@<bdi>polar-bear</bdi></a>, <a class="plugin-mentions-user plugin-mentions-a" href="/user/neil-schipper" aria-label="Profile: neil-schipper">@<bdi>neil-schipper</bdi></a> and <strong>All</strong>,</p>
<p dir="auto">This simple regex should work, too :</p>
<ul>
<li>
<p dir="auto">SEARCH <strong><code>(?-si)^(.+#0A5D00.+)\\[/b\\]</code></strong></p>
</li>
<li>
<p dir="auto">REPLACE <strong><code>$1</code></strong></p>
</li>
</ul>
<p dir="auto">Tick preferably the <strong><code>Wrap around</code></strong>  option</p>
<p dir="auto">Select the <strong><code>Regular expression</code></strong> search <strong>mode</strong></p>
<p dir="auto">Click, either, <strong>once</strong> on the <strong><code>Replace All</code></strong> button or <strong>several</strong> times on the <strong><code>Replace</code></strong> one</p>
<hr />
<p dir="auto"><strong>Notes</strong> :</p>
<ul>
<li>
<p dir="auto">The modifiers <strong><code>(?-is)</code></strong> assure that the <strong><code>. matches newline</code></strong> option is <strong>not</strong> checked and that the <strong><code>Match case</code></strong> option is <strong>checked</strong></p>
</li>
<li>
<p dir="auto">Then, after the <strong>beginning</strong> of line ( <strong><code>^</code></strong> ) the part <strong><code>.+#0A5D00.+</code></strong> matches all <strong>standard</strong> characters… till the string  <strong><code>#0A5D00</code></strong>, <strong>included</strong>, and then an other <strong>non-null</strong> range of <strong>standard</strong> characters till…</p>
</li>
<li>
<p dir="auto">…The <strong>literal</strong> string <strong><code>[/b]</code></strong> ( Note that the <strong>square</strong> brackets <strong><code>[</code></strong> and <strong><code>]</code></strong>, have a <strong>special</strong> signification in regexes. So, they must be <strong>escaped</strong> in order to search these characters <strong>literally</strong> )</p>
</li>
<li>
<p dir="auto">As the part <strong><code>.+#0A5D00.+</code></strong> is embedded in <strong>parentheses</strong>, it is stored as <strong>group <code>1</code></strong> and can be re-used, in the <strong>replacement</strong> regex, with the <strong><code>$1</code></strong> or <strong><code>\1</code></strong> syntax. So, the part <strong><code>\\[/b\\]</code></strong>, alone, is <strong>not</strong> rewritten !</p>
</li>
</ul>
<p dir="auto">Best Regards,</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/70849</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/70849</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Sun, 24 Oct 2021 09:31:51 GMT</pubDate></item><item><title><![CDATA[Reply to Deleting a group of characters in lines with same beginning and ending, but different in between (re-post) on Sun, 24 Oct 2021 09:25:16 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/neil-schipper" aria-label="Profile: Neil-Schipper">@<bdi>Neil-Schipper</bdi></a> And, since the match is only on what we want removed, we keep “Replace with” empty.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/70848</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/70848</guid><dc:creator><![CDATA[Neil Schipper]]></dc:creator><pubDate>Sun, 24 Oct 2021 09:25:16 GMT</pubDate></item><item><title><![CDATA[Reply to Deleting a group of characters in lines with same beginning and ending, but different in between (re-post) on Sun, 24 Oct 2021 09:21:37 GMT]]></title><description><![CDATA[<p dir="auto">Hi. You were sort of getting there, but you’re missing a few techniques:</p>
<ul>
<li>\Q…\E to force special characters (like square braces) to be treated as literal</li>
<li>* is not the simple wild card you may be used to</li>
<li>\K to throw away everything matched so far</li>
</ul>
<p dir="auto">This should do it: <code>\Q[m3][c #0A5D00]▸[i]\E.*?\K\Q[/b]\E</code></p>
]]></description><link>https://community.notepad-plus-plus.org/post/70847</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/70847</guid><dc:creator><![CDATA[Neil Schipper]]></dc:creator><pubDate>Sun, 24 Oct 2021 09:21:37 GMT</pubDate></item></channel></rss>