<?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[Loop or &quot;batch command&quot; - Search and Replace (especially regex) , in order to run multiple times the operation]]></title><description><![CDATA[<p dir="auto">hello. I just run a regex such as this:</p>
<p dir="auto">Search: <code>\s\S*(?:&lt;p class="best"&gt;|\G)(?:(?!&lt;/p&gt;).)*?\s\K\s+|(?&lt;=&lt;p class="best"&gt;)\s+|\s+(?=&lt;/p&gt;)</code><br />
Replace by: <code>(Leave Empty)</code></p>
<p dir="auto">This regex will delete/eliminate all the empty spaces from the tag <code>&lt;p class="best"&gt;</code>. But it cannot be done from the first attempt, so I must run many time this regex formula.</p>
<p dir="auto">I’m thinking of doing something like a “loop” or "batch command’, in order to run multiple times the operation, until is finally done all the “replaces”.</p>
<p dir="auto">Ho can I do this?</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/18567/loop-or-batch-command-search-and-replace-especially-regex-in-order-to-run-multiple-times-the-operation</link><generator>RSS for Node</generator><lastBuildDate>Thu, 11 Jun 2026 01:33:06 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/18567.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 02 Dec 2019 21:28:30 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Loop or &quot;batch command&quot; - Search and Replace (especially regex) , in order to run multiple times the operation on Wed, 04 Dec 2019 21:35:32 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/48927">Loop or "batch command" - Search and Replace (especially regex) , in order to run multiple times the operation</a>:</p>
<blockquote>
<p dir="auto">(?-si)(?&lt;=&lt;p class=“best”&gt;)\K\h*|\G((?!&lt;/p&gt;).)*?\K(\h+(?=&lt;/p&gt;)|\h\K\h+)</p>
</blockquote>
<p dir="auto">now, this is the best solution ! Probably, if I didn’t test other cases, it would not have been complete.</p>
<p dir="auto">thank you very much <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/48938</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/48938</guid><dc:creator><![CDATA[Vasile Caraus]]></dc:creator><pubDate>Wed, 04 Dec 2019 21:35:32 GMT</pubDate></item><item><title><![CDATA[Reply to Loop or &quot;batch command&quot; - Search and Replace (especially regex) , in order to run multiple times the operation on Wed, 04 Dec 2019 22:11:15 GMT]]></title><description><![CDATA[<p dir="auto">Hi, <a class="plugin-mentions-user plugin-mentions-a" href="/user/vasile-caraus" aria-label="Profile: vasile-caraus">@<bdi>vasile-caraus</bdi></a> and <strong>All</strong>,</p>
<p dir="auto">As always, regexes should <strong>always</strong> be processed against <strong>real user</strong> text ! <strong>Vasile</strong>, this issue has <strong>nothing</strong> related to <strong>leading tab</strong> characters ! It’s, simply, because, in your <strong><code>3rd</code></strong> and <strong><code>4th</code></strong> line, the <strong>starting</strong> tag is <strong>not</strong> followed with any <strong>space</strong> char !</p>
<p dir="auto">So :</p>
<p dir="auto">WRONG <strong><code>(?-si)(?&lt;=&lt;p class="best"&gt;)\K\h+|\G((?!&lt;/p&gt;).)*?\K(\h+(?=&lt;/p&gt;)|\h\K\h+)</code></strong></p>
<p dir="auto">RIGHT    <strong><code>(?-si)(?&lt;=&lt;p class="best"&gt;)\K\h*|\G((?!&lt;/p&gt;).)*?\K(\h+(?=&lt;/p&gt;)|\h\K\h+)</code></strong></p>
<p dir="auto">Indeed, because of the <strong><code>\G</code></strong> syntax and the fact that the <strong>dot</strong> <strong><code>.</code></strong> did <strong>not</strong> process <strong>EOL</strong> chars, when the regex engine processes possible blank characters before <strong><code>&lt;/p&gt;</code></strong>, the <strong>only</strong> possibility that the S/R process goes on and <strong>skips</strong> to <strong>next</strong> line is to match, <strong>first</strong>,  the <strong>first</strong> alternative of the regex, i.e. the new <strong>beginning</strong> part <strong><code>(?&lt;=&lt;p class="best"&gt;)\K\h*</code></strong>, which allows possible <strong>lack</strong> of <strong>blank</strong> chars ;-))</p>
<p dir="auto">Then, due to the <strong><code>\G</code></strong> feature, further <strong>blank</strong> characters on this <strong>next</strong> line can be <strong>deleted</strong> !</p>
<p dir="auto">So, from the text :</p>
<pre><code class="language-diff"> &lt;p class="best"&gt;  WORKS FINE        &lt;/p&gt;
&lt;p class="best"&gt;  WORKS FINE        &lt;/p&gt;
	&lt;p class="best"&gt;Why are you so beauty?        &lt;/p&gt;
	&lt;p class="best"&gt;I go   home. &lt;/p&gt;
</code></pre>
<p dir="auto">This time, we get, as <strong>expected</strong> :</p>
<pre><code class="language-diff"> &lt;p class="best"&gt;WORKS FINE&lt;/p&gt;
&lt;p class="best"&gt;WORKS FINE&lt;/p&gt;
	&lt;p class="best"&gt;Why are you so beauty?&lt;/p&gt;
	&lt;p class="best"&gt;I go home.&lt;/p&gt;
</code></pre>
<p dir="auto">BR</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/48927</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/48927</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Wed, 04 Dec 2019 22:11:15 GMT</pubDate></item><item><title><![CDATA[Reply to Loop or &quot;batch command&quot; - Search and Replace (especially regex) , in order to run multiple times the operation on Wed, 04 Dec 2019 16:59:12 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/vasile-caraus" aria-label="Profile: Vasile-Caraus">@<bdi>Vasile-Caraus</bdi></a> said in <a href="/post/48919">Loop or "batch command" - Search and Replace (especially regex) , in order to run multiple times the operation</a>:</p>
<blockquote>
<p dir="auto">people, calm down.</p>
</blockquote>
<p dir="auto">We’re calm.  We’re just trying to help you learn.</p>
<blockquote>
<p dir="auto">I came here for help.</p>
</blockquote>
<p dir="auto">Help us help you.  Show effort.  Give us a reason to want to continue to help you.  Right now, it feels like you’re asking us to do your homework (or worse, the job you’re being paid to do) for you, for free.</p>
<blockquote>
<p dir="auto">I am not a scientist, not  a programmer, just know how to use regex.</p>
</blockquote>
<p dir="auto">You don’t have to be a scientist nor a programmer to be able to follow advice and read documentation and try to understand what’s already been explained and given to you, and try to modify that to fit your actual needs.</p>
<blockquote>
<p dir="auto">No one is bound to help me.</p>
</blockquote>
<p dir="auto">Definitely true.  But using phrases like “Must change” makes it sound rather demanding.  (I understand that English might not be your native language.)</p>
<p dir="auto">But part of my definition of “help” is “help the person learn”, not “just give them the answer”.  If we help you to learn how to do this yourself, you could be much more efficient in writing your HTML website (waiting hours or days for one of us to write a regex for you is rather inefficient).  By encouraging you to learn regex yourself, rather than just relying on us to write the regex for you, we <em>are</em> trying to help you.</p>
<blockquote>
<p dir="auto">But maybe one day, this topic will come to the aid of someone else.</p>
</blockquote>
<p dir="auto">Indeed</p>
<blockquote>
<p dir="auto">And <a class="plugin-mentions-user plugin-mentions-a" href="/user/guy038" aria-label="Profile: guy038">@<bdi>guy038</bdi></a> is always here when need it.</p>
</blockquote>
<p dir="auto">Not always.  There have been long stretches when he’s not around.  And who knows, he might go the same way as others of the long-time contributors to the forum.  Or the forum may be killed off when Don gets tired of it.  In the long term, it’s better for you to learn.</p>
<p dir="auto">One of the best ways to learn regex is to study what’s been given, try to make changes that you <em>think</em> will work the way you want it to, and then ask specific questions if it doesn’t work as you expected.</p>
<p dir="auto">And one of the best ways to get the regex you want on the first time you ask the question, rather than having to do 3+ iterations, is to give truly-representative data sets. Make sure the example data you post includes both lines that you want to be changed and ones you don’t; make sure they include a reasonable variety of spacing variations, to make it clear when you want space to be important and when you don’t.</p>
<p dir="auto">This is all advice to help you learn, and to help you ask better questions in the future.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/48924</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/48924</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Wed, 04 Dec 2019 16:59:12 GMT</pubDate></item><item><title><![CDATA[Reply to Loop or &quot;batch command&quot; - Search and Replace (especially regex) , in order to run multiple times the operation on Wed, 04 Dec 2019 15:17:17 GMT]]></title><description><![CDATA[<p dir="auto">people, calm down. I came here for help. I am not a scientist, not  a programmer, just know how to use regex.  And if someone helps me with a solution, I try to make it the best solution. That’s all.</p>
<p dir="auto">I am a fan of Notepad ++, it helps me modify my .html files, because I have tried hard to make a website and I have a lot of bugs.</p>
<p dir="auto">No one is bound to help me. But maybe one day, this topic will come to the aid of someone else. And <a class="plugin-mentions-user plugin-mentions-a" href="/user/guy038" aria-label="Profile: guy038">@<bdi>guy038</bdi></a> is always here when need it.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/48919</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/48919</guid><dc:creator><![CDATA[Vasile Caraus]]></dc:creator><pubDate>Wed, 04 Dec 2019 15:17:17 GMT</pubDate></item><item><title><![CDATA[Reply to Loop or &quot;batch command&quot; - Search and Replace (especially regex) , in order to run multiple times the operation on Wed, 04 Dec 2019 15:07:42 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/48915">Loop or "batch command" - Search and Replace (especially regex) , in order to run multiple times the operation</a>:</p>
<blockquote>
<p dir="auto">This is the third time you’ve changed the requirements</p>
</blockquote>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/vasile-caraus" aria-label="Profile: Vasile-Caraus">@<bdi>Vasile-Caraus</bdi></a> gets spanked for this kind of thing a lot here.  He goes away for a while (licking his wounds) but then returns with the same approach.  :-(</p>
]]></description><link>https://community.notepad-plus-plus.org/post/48917</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/48917</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Wed, 04 Dec 2019 15:07:42 GMT</pubDate></item><item><title><![CDATA[Reply to Loop or &quot;batch command&quot; - Search and Replace (especially regex) , in order to run multiple times the operation on Wed, 04 Dec 2019 14:12:51 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/vasile-caraus" aria-label="Profile: Vasile-Caraus">@<bdi>Vasile-Caraus</bdi></a> said in <a href="/post/48912">Loop or "batch command" - Search and Replace (especially regex) , in order to run multiple times the operation</a>:</p>
<blockquote>
<p dir="auto">Almost :)</p>
</blockquote>
<p dir="auto">This is the third time you’ve changed the requirements after the original request.  If what Guy has given you is close, then using the examples and details that Guy has given you, plus the documentation linked in the <a href="https://community.notepad-plus-plus.org/topic/15765/faq-desk-where-to-find-regex-documentation">Community FAQ</a> or directly in the <a href="https://npp-user-manual.org/docs/searching/#regular-expressions" rel="nofollow ugc">official Notepad++ Documentation set</a>, you should be able to give it a try, and attempt to make your requested fixes yourself.</p>
<p dir="auto">After you’ve tried, if it works, great!  If not, show us what you tried, why you thought it would work, and give examples of how it didn’t work right.  We’re here to help you learn how to use the tool, not to just supply all your regexes without any effort from you.</p>
<p dir="auto">-----</p>
<h3>Please Read And Understand This</h3>
<p dir="auto">FYI: I often add this to my response in regex threads, unless I am sure the original poster has seen it before. Here is some helpful information for finding out more about regular expressions, and for formatting posts in this forum (especially quoting data) so that we can fully understand what you’re trying to ask:</p>
<blockquote>
<p dir="auto">This forum is formatted using <a href="https://daringfireball.net/projects/markdown/syntax" rel="nofollow ugc">Markdown</a>. Fortunately, it has a formatting toolbar above the edit window, and a preview window to the right; make use of those. The <code>&lt;/&gt;</code> button formats text as “code”, so that the text you format with that button will come through literally; use that formatting for example text that you want to make sure comes through literally, no matter what characters you use in the text (otherwise, the forum might interpret your example text as Markdown, with unexpected-for-you results, giving us a bad indication of what your data really is). Images can be pasted directly into your post, or you can hit the image button. (For more about how to manually use Markdown in this forum, please see <a href="https://community.notepad-plus-plus.org/topic/14262/how-to-markdown-code-on-this-forum/4">@Scott-Sumner’s post in the “how to markdown code on this forum” topic</a>, and my updates <a href="https://community.notepad-plus-plus.org/topic/14262/how-to-markdown-code-on-this-forum/9">near the end</a>.) Please use the preview window on the right to confirm that your text looks right before hitting SUBMIT. If you want to clearly communicate your text data to us, you <em>need</em> to properly format it.</p>
</blockquote>
<blockquote>
<p dir="auto">If you have further search-and-replace (“matching”, “marking”, “bookmarking”, regular expression, “regex”) needs, study <a href="https://npp-user-manual.org/docs/searching/#regular-expressions" rel="nofollow ugc">the official Notepad++ searching using regular-expressions docs</a>, as well as <a href="https://community.notepad-plus-plus.org/topic/15765/faq-desk-where-to-find-regex-documentation">this forum’s FAQ</a> and the documentation it points to. Before asking a new regex question, understand that for future requests, many of us will expect you to show what data you have (exactly), what data you want (exactly), what regex you already tried (to show that you’re showing effort), why you thought that regex would work (to prove it wasn’t just something randomly typed), and what data you’re getting with an explanation of why that result is wrong. When you show that effort, you’ll see us bend over backward to get things working for you. If you need help formatting, see the paragraph above.</p>
</blockquote>
<blockquote>
<p dir="auto">Please note that for all regex and related queries, it is best if you are explicit about what needs to match, <em>and</em> what <em>shouldn’t</em> match, and have multiple examples of both in your example dataset. Often, what <em>shouldn’t match</em> helps define the regular expression as much or more than what <em>should match</em>.</p>
</blockquote>
]]></description><link>https://community.notepad-plus-plus.org/post/48915</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/48915</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Wed, 04 Dec 2019 14:12:51 GMT</pubDate></item><item><title><![CDATA[Reply to Loop or &quot;batch command&quot; - Search and Replace (especially regex) , in order to run multiple times the operation on Wed, 04 Dec 2019 14:01:47 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/48905">Loop or "batch command" - Search and Replace (especially regex) , in order to run multiple times the operation</a>:</p>
<blockquote>
<p dir="auto">(?-si)(?&lt;=&lt;p class=“best”&gt;)\K\h+|\G((?!&lt;/p&gt;).)*?\K(\h+(?=&lt;/p&gt;)|\h\K\h+)</p>
</blockquote>
<p dir="auto">Almost :) Please see this case (the last 2 lines don’t change after using regex). Those have 2 tabs at before starting <code>&lt;p class..</code>. Please copy the text to see. Must change a little bit the regex. :)</p>
<pre><code> &lt;p class="best"&gt;  WORKS FINE        &lt;/p&gt;
&lt;p class="best"&gt;  WORKS FINE        &lt;/p&gt;
    &lt;p class="best"&gt;Why are you so beauty?        &lt;/p&gt;
    &lt;p class="best"&gt;I go   home. &lt;/p&gt;
</code></pre>
]]></description><link>https://community.notepad-plus-plus.org/post/48912</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/48912</guid><dc:creator><![CDATA[Vasile Caraus]]></dc:creator><pubDate>Wed, 04 Dec 2019 14:01:47 GMT</pubDate></item><item><title><![CDATA[Reply to Loop or &quot;batch command&quot; - Search and Replace (especially regex) , in order to run multiple times the operation on Wed, 04 Dec 2019 11:48:34 GMT]]></title><description><![CDATA[<p dir="auto">Hello, <a class="plugin-mentions-user plugin-mentions-a" href="/user/vasile-caraus" aria-label="Profile: vasile-caraus">@<bdi>vasile-caraus</bdi></a> and <strong>All</strong>,</p>
<p dir="auto">Ok ! Here is an <strong>other</strong> solution, <strong>slightly</strong> longer, which looks for :</p>
<ul>
<li>
<p dir="auto"><strong>All</strong> horizontal <strong>blank</strong> characters right <strong>after</strong> the string <strong><code>&lt;p class="best"&gt;</code></strong></p>
</li>
<li>
<p dir="auto"><strong>All</strong> horizontal <strong>blank</strong> characters right <strong>before</strong> the string <strong><code>&lt;/p&gt;</code></strong></p>
</li>
<li>
<p dir="auto">The <strong>excess</strong> horizontal <strong>blank</strong> characters, <strong>only</strong>, if they are <strong>not</strong> closed to the <strong>starting</strong> and/or <strong>ending</strong> tag</p>
</li>
</ul>
<p dir="auto">In the <strong>last</strong> case, this means that it <strong>skips</strong> all ranges of <strong><code>1-space</code></strong> long, <strong>not</strong> concerned by the <strong>S/R</strong></p>
<p dir="auto">SEARCH <strong><code>(?-si)(?&lt;=&lt;p class="best"&gt;)\K\h+|\G((?!&lt;/p&gt;).)*?\K(\h+(?=&lt;/p&gt;)|\h\K\h+)</code></strong></p>
<p dir="auto">REPLACE <strong><code>Leave EMPTY</code></strong></p>
<p dir="auto">Best Regards,</p>
<p dir="auto">guy038</p>
<p dir="auto"><strong>P.S.</strong> :</p>
<p dir="auto">This S/R <strong>does</strong> work, also, in the <strong>two</strong> particular cases, below :</p>
<pre><code class="language-diff">abc   def   &lt;p class="best"&gt;   Test    &lt;/p&gt;   abc   def

abc   def   &lt;p class="best"&gt;           &lt;/p&gt;   abc   def
</code></pre>
<p dir="auto">giving the results :</p>
<pre><code class="language-diff">abc   def   &lt;p class="best"&gt;Test&lt;/p&gt;   abc   def

abc   def   &lt;p class="best"&gt;&lt;/p&gt;   abc   def
</code></pre>
]]></description><link>https://community.notepad-plus-plus.org/post/48905</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/48905</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Wed, 04 Dec 2019 11:48:34 GMT</pubDate></item><item><title><![CDATA[Reply to Loop or &quot;batch command&quot; - Search and Replace (especially regex) , in order to run multiple times the operation on Tue, 03 Dec 2019 19:19:12 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/48873">Loop or "batch command" - Search and Replace (especially regex) , in order to run multiple times the operation</a>:</p>
<blockquote>
<p dir="auto">SEARCH (?-si)((&lt;p class=“best”&gt;)|\G)((?!&lt;/p&gt;).)*?\K\h+(?=(&lt;/p&gt;)|)</p>
<p dir="auto">REPLACE ?2:(?4:\x20)</p>
</blockquote>
<p dir="auto">your regex is GREAT for the first option, thank you.</p>
<p dir="auto">but, seems that I didn’t mention this one. In my html pages, I have both kind of lines. Some lines with tags that contains <strong>2-3 SPACES between words,</strong> and tags that have <strong>only one space</strong> (those are good).</p>
<p dir="auto">So, I need to Replace just those lines that have more then one space between words (like your regex, very good). But leave alone those who don’t have two or more spaces between words (such as the second line).</p>
]]></description><link>https://community.notepad-plus-plus.org/post/48882</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/48882</guid><dc:creator><![CDATA[Vasile Caraus]]></dc:creator><pubDate>Tue, 03 Dec 2019 19:19:12 GMT</pubDate></item><item><title><![CDATA[Reply to Loop or &quot;batch command&quot; - Search and Replace (especially regex) , in order to run multiple times the operation on Tue, 03 Dec 2019 15:49:11 GMT]]></title><description><![CDATA[<p dir="auto">Hi, <a class="plugin-mentions-user plugin-mentions-a" href="/user/vasile-caraus" aria-label="Profile: vasile-caraus">@<bdi>vasile-caraus</bdi></a> and <strong>All</strong>,</p>
<p dir="auto">Oooupps ! You’re quite <strong>right</strong> about it ! I didn’t notice the <strong>space</strong> character, right <strong>after</strong> <strong><code>&lt;p class="best"&gt;</code></strong> and right <strong>before</strong> <strong><code>&lt;/p&gt;</code></strong>, once the <strong>S/R</strong> is done :-((</p>
<p dir="auto">Here is one <strong>possible</strong> solution ( the <strong>shorter</strong> one that I could find out, yet ! ) :</p>
<p dir="auto">SEARCH <strong><code>(?-si)((&lt;p class="best"&gt;)|\G)((?!&lt;/p&gt;).)*?\K\h+(?=(&lt;/p&gt;)|)</code></strong></p>
<p dir="auto">REPLACE <strong><code>?2:(?4:\x20)</code></strong></p>
<p dir="auto"><strong>Notes</strong> : In replacement, the <strong>conditional</strong> syntaxes lead to the following <strong>logic</strong> :</p>
<ul>
<li>
<p dir="auto">If <strong>group <code>2</code></strong> exists ( the <strong>starting</strong> tag = <strong><code>&lt;p class="best"&gt;</code></strong> ), we do <strong>nothing</strong>, so the <strong>blank</strong> chars matched <strong><code>\h+</code></strong> are <strong>deleted</strong></p>
<ul>
<li>
<p dir="auto"><em>Else</em>, if <strong>group <code>4</code></strong> exists ( the <strong>ending</strong> tag = <strong><code>&lt;/p&gt;</code></strong> ), in the <strong>same</strong> way, the <strong>blank</strong> chars matched <strong><code>\h+</code></strong> are <strong>deleted</strong></p>
<ul>
<li><em>Else</em> ( case where <strong>blank</strong> character(s) matched ( <strong><code>\h+</code></strong> ) are, both, <strong>not</strong> preceded with <strong><code>&lt;p class="best"&gt;</code></strong> and <strong>not</strong> followed with <strong><code>&lt;/p&gt;</code></strong> ), a <strong>single <code>space</code></strong> char replaces the <strong>overall</strong> range of <strong>blank</strong> characters <strong><code>\h+</code></strong>, <strong>whatever</strong> they are !</li>
</ul>
</li>
</ul>
</li>
</ul>
<hr />
<p dir="auto">So, for instance, the text :</p>
<pre><code class="language-diff">abc   def   &lt;p class="best"&gt;   I go    home with my mother &lt;/em&gt; and my     father is watching tv.   &lt;/p&gt;   abc   def
</code></pre>
<p dir="auto">will be changed into :</p>
<pre><code class="language-diff">abc   def   &lt;p class="best"&gt;I go home with my mother &lt;/em&gt; and my father is watching tv.&lt;/p&gt;   abc   def
</code></pre>
<p dir="auto">Cheers,</p>
<p dir="auto">guy038</p>
<p dir="auto"><strong>P.S.</strong> :</p>
<p dir="auto">Within the <strong>positive</strong> look-behind, at the <strong>end</strong> of the regex, we may not use the <strong>alternation</strong> symbol <strong><code>|</code></strong> ) and use, instead, the <strong><code>(?=(&lt;/p&gt;)?)</code></strong> syntax, with the <strong>optional</strong> group <strong><code>&lt;/p&gt;</code></strong> ! The replacement regex is <strong>identical</strong></p>
]]></description><link>https://community.notepad-plus-plus.org/post/48873</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/48873</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Tue, 03 Dec 2019 15:49:11 GMT</pubDate></item><item><title><![CDATA[Reply to Loop or &quot;batch command&quot; - Search and Replace (especially regex) , in order to run multiple times the operation on Tue, 03 Dec 2019 10:28:48 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 Loop or “batch command” - Search and Replace (especially regex) , in order to run multiple times the operation:</p>
<p dir="auto"><code>(?-si)(&lt;p class=“best”&gt;|\G)((?!&lt;/p&gt;).)*?\h\K\h+</code></p>
<p dir="auto">Not very good. My regex seems to be better, even is too long. Also, your regex needs a lot of “Replace all”.</p>
<p dir="auto">Please see this example, after using your regex (and mine), you will see there are still empty spaces at the beginning of the row and at the end.</p>
<pre><code>&lt;p class="best"&gt; I go    home with my mother &lt;/em&gt; and my     father is watching tv. &lt;/p&gt;
</code></pre>
<p dir="auto">should become:</p>
<pre><code>&lt;p class="best"&gt;I go home with my mother &lt;/em&gt; and my father is watching tv.&lt;/p&gt;
</code></pre>
]]></description><link>https://community.notepad-plus-plus.org/post/48869</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/48869</guid><dc:creator><![CDATA[Vasile Caraus]]></dc:creator><pubDate>Tue, 03 Dec 2019 10:28:48 GMT</pubDate></item><item><title><![CDATA[Reply to Loop or &quot;batch command&quot; - Search and Replace (especially regex) , in order to run multiple times the operation on Mon, 02 Dec 2019 23:22:03 GMT]]></title><description><![CDATA[<p dir="auto">Hello <a class="plugin-mentions-user plugin-mentions-a" href="/user/vasile-caraus" aria-label="Profile: vasile-caraus">@<bdi>vasile-caraus</bdi></a> and <strong>All</strong>,</p>
<p dir="auto">If we assume that :</p>
<ul>
<li>
<p dir="auto">Any zone <strong><code>&lt;p class="best"&gt;........&lt;/p&gt;</code></strong> is a <strong>single line</strong> area of chars</p>
</li>
<li>
<p dir="auto">Any zone <strong><code>&lt;p class="best"&gt;........&lt;/p&gt;</code></strong> is a <strong>non-nested</strong> zone</p>
</li>
</ul>
<p dir="auto">I mean that the <strong>case</strong> <strong><code>........&lt;p class="best"&gt;.........&lt;p class="best"&gt;......    ..&lt;/p&gt;...       ..&lt;/p&gt;.......</code></strong> <strong>never</strong> happens</p>
<p dir="auto">Then, the regex, below, will get rid of <strong>all excedentary horizontal blank</strong> characters, between any <strong>starting</strong> tag <strong><code>&lt;p class="best"&gt;</code></strong>, with that <strong>exact</strong> case, and its <strong>ending</strong> tag <strong><code>&lt;/p&gt;</code></strong>.</p>
<p dir="auto">Note that text, in <strong>current</strong> line, <strong>before</strong> the starting tag.<strong><code>&lt;p class="best"&gt;</code></strong> and <strong>after</strong> the ending tag <strong><code>&lt;/p&gt;</code></strong> is <strong>not</strong> concerned by this <strong>S/R</strong></p>
<p dir="auto">SEARCH <strong><code>(?-si)(&lt;p class="best"&gt;|\G)((?!&lt;/p&gt;).)*?\h\K\h+</code></strong></p>
<p dir="auto">REPLACE <strong><code>Leave Empty</code></strong></p>
<p dir="auto">Simply, click, <strong>once</strong>, on the <strong><code>Replace All</code></strong> button</p>
<p dir="auto"><strong>Remark</strong> : I did not use <strong>non-capturing</strong> group as the <strong>first</strong> group represent a <strong><code>16-chars</code></strong> string or the <strong><code>0-char</code></strong> assertion <strong><code>\G</code></strong> and the <strong>second</strong> group is a <strong><code>1-char</code></strong> string, anyway !</p>
<p dir="auto">Best Regards,</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/48861</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/48861</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Mon, 02 Dec 2019 23:22:03 GMT</pubDate></item></channel></rss>