<?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[Regex: How to remove enewline character from a particular html tags?]]></title><description><![CDATA[<p dir="auto">I have this html tag, which is interrupted by /n at some point after word <code>masuri:</code></p>
<pre><code>&lt;p class="mb-40px"&gt;Aceasta este o melodie alcatuita din patru masuri:
reluata apoi de catre instrumentul solist cu un cintec popular.&lt;/p&gt;
</code></pre>
<p dir="auto">THE OUTPUT must be:</p>
<pre><code>&lt;p class="mb-40px"&gt;Aceasta este o melodie alcatuita din patru masuri: reluata apoi de catre instrumentul solist cu un cintec popular.&lt;/p&gt;
</code></pre>
<p dir="auto">I try this regex, but doesn’t work too good, because is also change the entire html code, not just that particular tag.</p>
<p dir="auto">FIND: <code>(?:&lt;p class="mb-40px"&gt;|\G)(?:(?!&lt;/p&gt;).)*?\K(\r\n|\r|\n)</code></p>
<p dir="auto">REPLACE BY: <code>\x20</code></p>
<p dir="auto">Also, I find a solution of <a class="plugin-mentions-user plugin-mentions-a" href="/user/neil-schipper" aria-label="Profile: neil-schipper">@<bdi>neil-schipper</bdi></a> from a page on this forum, but I don’t know how to integrate with my html tag :</p>
<p dir="auto">FIND: <code>(?&lt;=[^\r\n])\R(?=[^\r\n])</code><br />
REPLACE BY: <code>(LEAVE EMPTY)</code></p>
]]></description><link>https://community.notepad-plus-plus.org/topic/22647/regex-how-to-remove-enewline-character-from-a-particular-html-tags</link><generator>RSS for Node</generator><lastBuildDate>Sun, 17 May 2026 18:37:03 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/22647.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 27 Feb 2022 20:48:16 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Regex: How to remove enewline character from a particular html tags? on Mon, 12 Aug 2024 09:46:41 GMT]]></title><description><![CDATA[<p dir="auto">The best solution is this:</p>
<p dir="auto"><code>(?-si:&lt;p class=".+?"&gt;|(?!\A)\G)(?s-i:(?!&lt;/p&gt;).)*?\K\s+</code></p>
<p dir="auto">General regex: <code>(?-si:BSR|(?!\A)\G)(?s-i:(?!ESR).)*?\KFR</code></p>
]]></description><link>https://community.notepad-plus-plus.org/post/96121</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/96121</guid><dc:creator><![CDATA[Hellena Crainicu]]></dc:creator><pubDate>Mon, 12 Aug 2024 09:46:41 GMT</pubDate></item><item><title><![CDATA[Reply to Regex: How to remove enewline character from a particular html tags? on Thu, 10 Mar 2022 13:25:31 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/74678">Regex: How to remove enewline character from a particular html tags?</a>:</p>
<blockquote>
<p dir="auto">Why should you be believed over <a class="plugin-mentions-user plugin-mentions-a" href="/user/guy038" aria-label="Profile: guy038">@<bdi>guy038</bdi></a> ?</p>
</blockquote>
<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/75050">Regex: How to remove enewline character from a particular html tags?</a>:</p>
<blockquote>
<p dir="auto">Now, the generic variants, proposed by <a class="plugin-mentions-user plugin-mentions-a" href="/user/robin-cruise" aria-label="Profile: Robin-cruise">@<bdi>Robin-cruise</bdi></a> and <a class="plugin-mentions-user plugin-mentions-a" href="/user/hellena-crainicu" aria-label="Profile: hellena-crainicu">@<bdi>hellena-crainicu</bdi></a>, with a final look-ahead only, containing the ESR region will not work, most of a time :-(</p>
</blockquote>
<hr />
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/robin-cruise" aria-label="Profile: Robin-cruise">@<bdi>Robin-cruise</bdi></a> and <a class="plugin-mentions-user plugin-mentions-a" href="/user/hellena-crainicu" aria-label="Profile: hellena-crainicu">@<bdi>hellena-crainicu</bdi></a> :</p>
<p dir="auto">Be careful of posting simplifications.</p>
<p dir="auto">Probably best to leave these things to the “Master”. :-)</p>
]]></description><link>https://community.notepad-plus-plus.org/post/75051</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/75051</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Thu, 10 Mar 2022 13:25:31 GMT</pubDate></item><item><title><![CDATA[Reply to Regex: How to remove enewline character from a particular html tags? on Thu, 10 Mar 2022 13:56:55 GMT]]></title><description><![CDATA[<p dir="auto">Hello, @rovbin-cruise, <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/hellena-crainicu" aria-label="Profile: hellena-crainicu">@<bdi>hellena-crainicu</bdi></a> and <strong>All</strong>,</p>
<p dir="auto">Refering to my <strong>first</strong> blog post about a <strong>generic</strong> regex, below :</p>
<p dir="auto"><a href="https://community.notepad-plus-plus.org/post/75007">https://community.notepad-plus-plus.org/post/75007</a></p>
<p dir="auto">and as <strong>Robin</strong> want to search for <strong>line-ending</strong> chars, we need to use, of course the <strong>complete</strong> generic regex S/R :</p>
<p dir="auto">SEARCH <strong><code>(?-si:</code>BSR<code>|(?!\A)\G)(?s-i:(?!</code>ESR<code>).)*?\K(?-si:</code>FR<code>)</code></strong></p>
<p dir="auto">REPLACE <strong>RR</strong></p>
<p dir="auto">and <strong>not</strong> the simplified <strong>single</strong>-line version</p>
<hr />
<p dir="auto">So :</p>
<ul>
<li>
<p dir="auto">The <strong>FR</strong> regex is just <strong><code>\R</code></strong>, as the <strong>non-capturing</strong> associated group, beginning with <strong><code>(?_si:...</code></strong>, is <strong>useless</strong> in this case</p>
</li>
<li>
<p dir="auto">The <strong>RR</strong> regex is <strong><code>\x20</code></strong></p>
</li>
<li>
<p dir="auto">The <strong>BSR</strong> regex may be <strong>strictly</strong> the string <strong><code>&lt;p class="mb-40px"&gt;</code></strong> but may also be expressed as <strong><code>&lt;p class=".+?"&gt;</code></strong></p>
</li>
<li>
<p dir="auto">The <strong>ESR</strong> regex is, of course, the ending tag <strong><code>&lt;/p&gt;</code></strong>, which must <strong>never</strong> occurs before the next <strong>line-ending</strong> to replace</p>
</li>
</ul>
<p dir="auto">giving the <strong>functional</strong> regex S/R :</p>
<p dir="auto">SEARCH <strong><code>(?-si:&lt;p class=".+?"&gt;|(?!\A)\G)(?s-i:(?!&lt;/p&gt;).)*?\K\R</code></strong></p>
<p dir="auto">REPLACE <strong><code>\x20</code></strong></p>
<p dir="auto">Test it against that text :</p>
<pre><code class="language-html">&lt;a href="https://www.w3schools.com/"&gt;We strongly suggest
to visit the
w3schools.com
site&lt;/a&gt;

&lt;p class="mb-40px"&gt;Aceasta
este o melodie alcatuita
din patru masuri:
reluata apoi de catre instrumentul solist
cu un cintec popular.&lt;/p&gt;

&lt;p class="Test"&gt;A SINGLE line&lt;/p&gt;

&lt;h1&gt;this is
my very
first heading
&lt;/h1&gt;

&lt;p class="123-456 789"&gt;This is	
a quick
text to
verify if it
replaces line-endings
by a space char in &lt;p&gt;
tags ONLY&lt;/p&gt;
</code></pre>
<p dir="auto"><em>ONLY</em> the <strong><code>&lt;p class.............&lt;p&gt;</code></strong>, <strong>multi</strong>-lines or <strong>not</strong>, should be concerned by the <strong>replacement</strong> !</p>
<p dir="auto">Of course, these <strong><code>HTML</code></strong> commands do not represent a <strong>legal</strong> <strong><code>HTML</code></strong> file and are just used to <strong>verify</strong> the regex S/R !</p>
<hr />
<p dir="auto">Now, the <strong>generic</strong> variants, proposed by <a class="plugin-mentions-user plugin-mentions-a" href="/user/robin-cruise" aria-label="Profile: Robin-cruise">@<bdi>Robin-cruise</bdi></a> and <a class="plugin-mentions-user plugin-mentions-a" href="/user/hellena-crainicu" aria-label="Profile: hellena-crainicu">@<bdi>hellena-crainicu</bdi></a>, with a final <strong>look-ahead</strong> only, containing the <strong>ESR</strong> region, will <strong>not</strong> work, most of a time :-(</p>
<p dir="auto">SEARCH <strong><code>(?-si:</code>BSR<code>|(?!\A)\G).*?\K(?-si:</code>FR<code>)(?=(?s-i:.*?</code>ESR<code>))</code></strong></p>
<p dir="auto">In our case, the <strong>functional</strong> regex S/R becomes :</p>
<p dir="auto">SEARCH <strong><code>(?-si:&lt;p class=".+?"&gt;|(?!\A)\G).*?\K\R(?=(?s-i:.*?&lt;/p&gt;))</code></strong></p>
<p dir="auto">REPLACE <strong><code>\x20</code></strong></p>
<p dir="auto"><strong>But</strong> if you test it against, for instance :</p>
<pre><code class="language-html">
&lt;p class="Test"&gt;Several
consecutive
lines&lt;/p&gt;

&lt;h1&gt;this is
my very
first heading
&lt;/h1&gt;

&lt;p class="Test"&gt;A SINGLE line&lt;/p&gt;

&lt;h2&gt;this is
my second
heading
&lt;/h2&gt;
</code></pre>
<p dir="auto">It would <strong>concatenate</strong> all text till the <strong>last</strong> <strong><code>&lt;/p&gt;</code></strong> of the file, just leaving the last <strong><code>&lt;h2&gt;</code></strong> tag <strong>untouched</strong>. You could say : But I <strong>did</strong> add a final <strong>question mark</strong> in order to get a <strong>lazy</strong> range of chars before <strong><code>&lt;/p&gt;</code></strong> !</p>
<p dir="auto">You’re <strong>right</strong> ! But remember that the regex engine tries, by <strong>all</strong> means, to get a <strong>solution</strong>. So, it matches the <strong><code>CRLF</code></strong> chars, which follow <strong>lines<code>&lt;/p&gt;</code></strong>, because the regex engine considers that the <strong><code>.*?</code></strong> <strong>lazy</strong> range of chars begins <strong>immediately</strong> after the <strong>line-ending</strong> and continues till <strong>right before</strong> the <strong>third</strong> and final <strong><code>&lt;/p&gt;</code></strong>, so defining a <strong>correct</strong> look-ahead assertion !</p>
<p dir="auto">Thus, testing if the <strong>ESR</strong> region is not reached at <strong>any</strong> position, till a <em>NEXT</em> <strong>FR</strong> match, seems the <strong>only</strong> method which works  properly !</p>
<p dir="auto">Best Regards</p>
<p dir="auto">guy038</p>
<p dir="auto">Reminder : Move to the <strong>very beginning</strong> of text before clicking on the <strong><code>Find Next</code></strong> or <strong><code>Replace All</code></strong> button !</p>
]]></description><link>https://community.notepad-plus-plus.org/post/75050</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/75050</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Thu, 10 Mar 2022 13:56:55 GMT</pubDate></item><item><title><![CDATA[Reply to Regex: How to remove enewline character from a particular html tags? on Wed, 09 Mar 2022 07:10:31 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> <a class="plugin-mentions-user plugin-mentions-a" href="/user/guy038" aria-label="Profile: guy038">@<bdi>guy038</bdi></a></p>
<p dir="auto">another alternative of Robin’s generic, a better version, can be:</p>
<p dir="auto"><code>(REGION-START)+(.)+\K(FIND REGEX)(?s:(?=.*(REGION-FINAL)))</code></p>
]]></description><link>https://community.notepad-plus-plus.org/post/75013</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/75013</guid><dc:creator><![CDATA[Hellena Crainicu]]></dc:creator><pubDate>Wed, 09 Mar 2022 07:10:31 GMT</pubDate></item><item><title><![CDATA[Reply to Regex: How to remove enewline character from a particular html tags? on Mon, 28 Feb 2022 12:35:16 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/robin-cruise" aria-label="Profile: robin-cruise">@<bdi>robin-cruise</bdi></a> said in <a href="/post/74668">Regex: How to remove enewline character from a particular html tags?</a>:</p>
<blockquote>
<p dir="auto">The below GENERIC regex formula can be much simple made then <a class="plugin-mentions-user plugin-mentions-a" href="/user/guy038" aria-label="Profile: guy038">@<bdi>guy038</bdi></a> made</p>
</blockquote>
<p dir="auto">Why should you be believed over <a class="plugin-mentions-user plugin-mentions-a" href="/user/guy038" aria-label="Profile: guy038">@<bdi>guy038</bdi></a> ?</p>
]]></description><link>https://community.notepad-plus-plus.org/post/74678</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/74678</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Mon, 28 Feb 2022 12:35:16 GMT</pubDate></item><item><title><![CDATA[Reply to Regex: How to remove enewline character from a particular html tags? on Mon, 28 Feb 2022 07:12:48 GMT]]></title><description><![CDATA[<p dir="auto">Another solution: <code>(\r\n|\r|\n)</code></p>
<p dir="auto">FIND: <code>(&lt;p class="mb-40px"&gt;)+(.)+\K(\r\n|\r|\n)(?=.*&lt;\/p&gt;)</code></p>
<p dir="auto">REPLACE BY: <code>\x20</code></p>
<p dir="auto">The below GENERIC regex formula can be much simple made then <a class="plugin-mentions-user plugin-mentions-a" href="/user/guy038" aria-label="Profile: guy038">@<bdi>guy038</bdi></a> made in many other of his GENERIC regex formulas:</p>
<p dir="auto"><code>(REGION-START)+(.)+\K(FIND REGEX)(?=.*REGION-FINAL)</code></p>
]]></description><link>https://community.notepad-plus-plus.org/post/74668</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/74668</guid><dc:creator><![CDATA[Robin Cruise]]></dc:creator><pubDate>Mon, 28 Feb 2022 07:12:48 GMT</pubDate></item><item><title><![CDATA[Reply to Regex: How to remove enewline character from a particular html tags? on Sun, 27 Feb 2022 22:10:30 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, it works !!</p>
<p dir="auto">Find: <code>(?-i:&lt;p class="mb-40px"&gt;|(?!\A)\G)(?s:(?!&lt;/p&gt;).)*?\K(?-i:(?&lt;=[^\r\n])\R(?=[^\r\n]))</code></p>
<p dir="auto">Replace by: <code>\x20</code></p>
]]></description><link>https://community.notepad-plus-plus.org/post/74662</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/74662</guid><dc:creator><![CDATA[Robin Cruise]]></dc:creator><pubDate>Sun, 27 Feb 2022 22:10:30 GMT</pubDate></item><item><title><![CDATA[Reply to Regex: How to remove enewline character from a particular html tags? on Sun, 27 Feb 2022 20:53:19 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/robin-cruise" aria-label="Profile: robin-cruise">@<bdi>robin-cruise</bdi></a></p>
<p dir="auto">This is just a (by now) simple replace-but-only-between-delimiters problem; see <a href="https://community.notepad-plus-plus.org/post/62799">HERE</a> for the templatized solution.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/74659</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/74659</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Sun, 27 Feb 2022 20:53:19 GMT</pubDate></item></channel></rss>