<?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[How to combine a multi-line html element into one line?]]></title><description><![CDATA[<p dir="auto">I don’t know why I’m having trouble with this, but suppose I have the following:</p>
<pre><code>&lt;p&gt;Lorem ipsum dolor sit amet, libero turpis non cras ligula, 
id commodo, aenean est in volutpat amet sodales, 
porttitor bibendum facilisi &lt;/p&gt;
&lt;p&gt;Donec vivamus. Vel donec et scelerisque vestibulum. 
Condimentum aliquam, mollit magna velit nec, tempor cursus 
vitae sit aliquet neque purus.&lt;/p&gt;
&lt;p&gt;Iaculis et dui ullamcorper, non egestas condimentum dui 
phasellus. Sit non mattis a, leo in imperdiet erat nec 
pulvinar. Ornare massa justo&lt;/p&gt;
&lt;p&gt;Rhoncus lacinia. Imperdiet nulla sem fringilla, purus 
enim amet, nascetur faucibus, adipiscing neque ut bibendum, 
at felis nec in. Mauris&lt;/p&gt;
</code></pre>
<p dir="auto">…and I want to put the contents of each <code>&lt;p&gt;</code> element onto the same line:</p>
<pre><code>&lt;p&gt;Lorem ipsum dolor sit amet, libero turpis non cras ligula, id commodo, aenean est in volutpat amet sodales, porttitor bibendum facilisi &lt;/p&gt;
&lt;p&gt;Donec vivamus. Vel donec et scelerisque vestibulum. Condimentum aliquam, mollit magna velit nec, tempor cursus vitae sit aliquet neque purus.&lt;/p&gt;
&lt;p&gt;Iaculis et dui ullamcorper, non egestas condimentum dui phasellus. Sit non mattis a, leo in imperdiet erat nec pulvinar. Ornare massa justo&lt;/p&gt;
&lt;p&gt;Rhoncus lacinia. Imperdiet nulla sem fringilla, purus enim amet, nascetur faucibus, adipiscing neque ut bibendum, at felis nec in. Mauris&lt;/p&gt;
</code></pre>
<p dir="auto">I have tried something like search: “<code>(&lt;p.*?)(?&lt;!&lt;\/p&gt;)\R +</code>” and replacing it with "<code>\1 </code>", but besides the fact that it won’t do multiple lines at once (I have to keep repeating the search/replace), the main issue is that if there is a line that starts with a <code>&lt;p&gt;</code> and ends with a <code>&lt;/p&gt;</code>, it matches the whole line and whatever comes after it.</p>
<p dir="auto">What’s the best way to construct this search and replace?</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/26431/how-to-combine-a-multi-line-html-element-into-one-line</link><generator>RSS for Node</generator><lastBuildDate>Sun, 14 Jun 2026 12:58:26 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/26431.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 05 Dec 2024 03:36:04 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to How to combine a multi-line html element into one line? on Thu, 05 Dec 2024 05:28:05 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/pbarney" aria-label="Profile: pbarney">@<bdi>pbarney</bdi></a> said in <a href="/post/98401">How to combine a multi-line html element into one line?</a>:</p>
<blockquote>
<p dir="auto">What’s the best way to construct this search and replace?</p>
</blockquote>
<p dir="auto">A similar question was posted some time ago <a href="https://community.notepad-plus-plus.org/topic/25392/regex-finding-invalid-characters-in-html-tags">here</a>. I suggest reading that. As you seem to be proficient at regex hopefully you can adjust to suit your need.</p>
<p dir="auto">Terry</p>
]]></description><link>https://community.notepad-plus-plus.org/post/98403</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/98403</guid><dc:creator><![CDATA[Terry R]]></dc:creator><pubDate>Thu, 05 Dec 2024 05:28:05 GMT</pubDate></item><item><title><![CDATA[Reply to How to combine a multi-line html element into one line? on Thu, 05 Dec 2024 05:30:30 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/pbarney" aria-label="Profile: pbarney">@<bdi>pbarney</bdi></a></p>
<p dir="auto">This is a classic case of guy038’s patented <a href="https://community.notepad-plus-plus.org/topic/22690/generic-regex-replacing-in-a-specific-zone-of-text">“replace in a specific zone of text” regex</a> (follow link for an explanation of how this regex works).</p>
<p dir="auto">Simply replace <code>(?s-i)(?:&lt;p&gt;|(?!\A)\G)(?:(?!&lt;/p&gt;).)*?\K\R</code> with nothing.</p>
<p dir="auto">Essentially, everything after the <code>\K</code> is what you want to remove, and everything before the <code>\K</code> is ensuring that the replacements only happen within <code>&lt;p&gt;</code> tags.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/98402</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/98402</guid><dc:creator><![CDATA[Mark Olson]]></dc:creator><pubDate>Thu, 05 Dec 2024 05:30:30 GMT</pubDate></item></channel></rss>