<?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[HELP! Replace spaces in text ONLY between quotes?]]></title><description><![CDATA[<p dir="auto">HELP! I have a script that needs editing. In it, it has calls to over 200 filenames.</p>
<p dir="auto">I discovered too late that the filenames can not contain spaces. Renaming the files themselves was easy with a Bulk Rename Utility, but now I have several hundred references to those files in my scripts and it would take me DAYS to replace the spaces in all those filename references with underscore “_” characters.</p>
<p dir="auto">A global Search/Replace of EVERY space, with an underscore obviously is not an option.</p>
<p dir="auto">Might there be a way to replace only spaces in lines of text that appear between quotes? Even a “wildcard” for the characters surrounding a space would be helpful.</p>
<p dir="auto">Big TIA.</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/19556/help-replace-spaces-in-text-only-between-quotes</link><generator>RSS for Node</generator><lastBuildDate>Wed, 22 Apr 2026 03:07:24 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/19556.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 15 Jun 2020 18:57:44 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to HELP! Replace spaces in text ONLY between quotes? on Thu, 02 Jul 2020 14:07:16 GMT]]></title><description><![CDATA[<p dir="auto">Hi, @alan-kilobrn and <strong>All</strong>,</p>
<p dir="auto">Well, here it is ! I found a <strong>regex</strong> structure and some <strong>variants</strong>, which do the trick very <strong>nicely</strong> ;-))</p>
<p dir="auto">Let’s define these <strong><code>4</code></strong> variables :</p>
<ul>
<li>
<p dir="auto"><strong>Srch_Expr</strong> = <strong><code>Char|String|Regex</code></strong></p>
</li>
<li>
<p dir="auto"><strong>Repl_Text</strong> = <strong><code>Char|String|Regex</code></strong></p>
</li>
<li>
<p dir="auto"><strong>Opn_Del</strong> = <strong><code>Char</code></strong></p>
</li>
<li>
<p dir="auto"><strong>End_Del</strong> = <strong><code>Char</code></strong></p>
</li>
</ul>
<p dir="auto">Then the <strong><code>Search_Replacement_A</code></strong>, which matches any <strong>Srch_Expr</strong>, <em>ONLY WHEN</em>  located between the <strong>Opn_Del</strong> and the <strong>End_Del</strong> delimiter(s), is :</p>
<ul>
<li>
<p dir="auto">SEARCH <strong>Srch_Expr<code>(?=[^</code>Opn_Del<code>]*?</code>End_Del<code>)</code></strong></p>
</li>
<li>
<p dir="auto">REPLACE <strong>Repl_Text</strong></p>
</li>
</ul>
<hr />
<p dir="auto"><strong>Rules</strong> and <strong>Remarks</strong> :</p>
<ul>
<li>
<p dir="auto">The <strong>Opn_Del</strong> and <strong>End_Del</strong> delimiters represent, both, a <strong>single</strong> char, which may be :</p>
<ul>
<li>
<p dir="auto">Characters <strong>already</strong> present of the <strong>current</strong> file</p>
</li>
<li>
<p dir="auto">Characters presently <strong>absent</strong> in <strong>current</strong> file and <strong>manually</strong> added by the <strong>user</strong> ( Verify with the <strong><code>Count</code></strong> feature they are <strong>new</strong> chars ! )</p>
</li>
</ul>
</li>
</ul>
<hr />
<ul>
<li>
<p dir="auto">In case, of <strong>added</strong> delimiters, use, preferably, the <strong><code>Search_Replacement_B</code></strong>, below, which <strong>deletes</strong> these <strong>temporary</strong> delimiters, at the <strong>same</strong> time :</p>
<ul>
<li>
<p dir="auto">SEARCH <strong>Opn_Del<code>|(</code>Srch_Expr<code>)(?=[^</code>Opn_Del<code>]*?</code>End_Del<code>)|</code>End_Del</strong></p>
</li>
<li>
<p dir="auto">REPLACE <strong><code>?1</code>Repl_Text</strong></p>
</li>
</ul>
</li>
</ul>
<hr />
<ul>
<li>
<p dir="auto">The <strong>Opn_Del</strong> and <strong>End_Del</strong> delimiters must <strong>not</strong> be <strong>identical</strong>. If <strong>NOT</strong> ( usually, <strong>cases</strong> <strong><code>"...."</code></strong> or <strong><code>'....'</code></strong> ), perform the following <strong>regex</strong> S/R, <strong><code>first</code></strong> :</p>
<ul>
<li>
<p dir="auto">SEARCH <strong>Delim<code>(.+?)</code>Delim</strong></p>
</li>
<li>
<p dir="auto">REPLACE <strong>Opn_Del<code>\1</code>End_Del</strong><br />
<code> </code></p>
</li>
<li>
<p dir="auto">Then, execute the <strong><code>Search_Replacement_C</code></strong>, which rewrites, as well, the initial <strong>double</strong> delimiters <strong>Delim</strong> :</p>
<ul>
<li>
<p dir="auto">SEARCH <strong>Opn_Del<code>|(</code>Srch_Expr<code>)(?=[^</code>Opn_Del<code>]*?</code>End_Del<code>)|</code>End_Del</strong></p>
</li>
<li>
<p dir="auto">REPLACE <strong><code>?1</code>Repl_Text<code>:</code>Delim</strong></p>
</li>
</ul>
</li>
</ul>
</li>
</ul>
<hr />
<ul>
<li>
<p dir="auto">In case that the <strong>last</strong> zone <strong>Opn_Del<code>......</code>End_Del</strong> ends at the <strong>very end</strong> of current file, the <strong>End_Del</strong> delimiter, of the <strong>last</strong> zone, can be <strong>omitted</strong> and you’ll use the <strong><code>Search_Replacement_D</code></strong>, below :</p>
<ul>
<li>
<p dir="auto">SEARCH <strong>Srch_Expr<code>(?=[^</code>Opn_Del<code>]*?(</code>End_Del<code>|\z))</code></strong></p>
</li>
<li>
<p dir="auto">REPLACE <strong>Repl_Text</strong></p>
</li>
</ul>
</li>
</ul>
<hr />
<ul>
<li>
<p dir="auto">The different zones, between <strong>delimiters</strong>, must be <strong>complete</strong>, with their <strong>matched</strong> different delimiters ( <strong>Open_Del<code>......</code>End_Del</strong> )</p>
</li>
<li>
<p dir="auto">The different zones, between <strong>delimiters</strong>, may be <strong>juxtaposed</strong> but <strong>NOT</strong> nested</p>
</li>
<li>
<p dir="auto">A zone can lie in a <strong>single</strong> line or split over <strong>several</strong> lines</p>
</li>
<li>
<p dir="auto"><strong>Srch_Expr</strong> must <strong>not</strong> match the <strong>Opn_Del</strong> delimiter, or <strong>part</strong> of it</p>
</li>
</ul>
<hr />
<p dir="auto">As an <strong>example</strong>, let’s use the <strong><code>license.txt</code></strong> file and define :</p>
<ul>
<li>
<p dir="auto"><strong>Opn_Del</strong> <strong><code>&amp;</code></strong></p>
</li>
<li>
<p dir="auto"><strong>End_Del</strong> <strong><code>#</code></strong></p>
</li>
<li>
<p dir="auto"><strong>Srch_Expr</strong> <strong><code>\w+</code></strong></p>
</li>
</ul>
<p dir="auto">I <strong>previously</strong> verified that, both, these <strong>two</strong> symbols do <strong>not</strong> exist in the <strong><code>license.txt</code></strong> file</p>
<ul>
<li>Place <strong>one</strong> or <strong>several</strong> zones <strong><code>&amp;......#</code></strong>, <strong>anywhere</strong> in this file. The zones may be split on <strong>several</strong> lines, with the <strong>OplDel</strong> <strong><code>&amp;</code></strong> in a line and an <strong>End_Del</strong> <strong><code>#</code></strong> on a <strong>further</strong> line</li>
</ul>
<p dir="auto">So, the <strong>appropriate</strong> search <strong><code>regex_A</code></strong> is :</p>
<p dir="auto">SEARCH <strong><code>\w+(?=[^&amp;]*?#)</code></strong></p>
<p dir="auto">And imagine that we want to <strong>surround</strong> any word with strings <strong><code>[--</code></strong> and <strong><code>--]</code></strong>, in zones <strong><code>&amp;............#</code></strong>, <strong>ONLY</strong>. Hence, the <strong>replace</strong> <strong><code>Regex_A</code></strong> is :</p>
<p dir="auto">REPLACE <strong><code>[--$0--]</code></strong></p>
<hr />
<p dir="auto">With the <strong>same</strong> delimiters, let’s suppose that we want, this time, to find any <strong>single standard</strong> char, so the regex <strong><code>(?-s).</code></strong> and to replace it with an <strong>underscore</strong> <strong><code>_</code></strong> char</p>
<p dir="auto">However, regarding the <strong>rules</strong> above, this regex should <strong>not</strong> match the <strong>Opn_Del</strong> delimiter. This can be achieved with the <strong>regex</strong> <strong><code>(?-s)(?!&amp;).</code></strong>, giving the following <strong><code>Search_Replacement_A</code></strong> :</p>
<p dir="auto">SEARCH <strong><code>(?-s)(?!&amp;).(?=[^&amp;]*?#)</code></strong></p>
<p dir="auto">REPLACE <strong><code>_</code></strong></p>
<hr />
<p dir="auto">Now, <strong>Alan</strong> I also found a regex which works when <strong>delimiters</strong> are simple <strong>words</strong>  as for instance, <strong>STT</strong> and <strong>END</strong> and not <strong>single</strong> characters :</p>
<ul>
<li><strong><code>Regex_E</code></strong> = <strong>Srch_Expr<code>(?=(?s-i:(?:(?!</code>Opn_Del<code>).)*?</code>End_Del<code>))</code></strong></li>
</ul>
<p dir="auto">Unfortunately, due to the <strong>negative look-ahead</strong> syntax, <strong><code>(?!</code>Opn_Del<code>).)</code></strong>, this regex bugges, even with the light <strong>license.txt</strong> file :-(( You know : the <strong>final</strong> wrong “<em>all contents</em>” match ! But it works nice when <strong>few</strong> lines are involved !</p>
<p dir="auto">The <strong>safe</strong> solution, in that case, is to replace <strong>word</strong> delimiters with <strong>char</strong> delimiters, first ( for instance <strong>STT</strong> -&gt; <strong><code>&amp;</code></strong> and <strong>END</strong> -&gt; <strong><code>#</code></strong> )</p>
<hr />
<p dir="auto">Finally, a possible  <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/15302">@mugsys-rapSheet</a>’s solution, much <strong>shorter</strong>, using the <strong>generic</strong> <strong><code>Search_Replacement_C</code></strong>, could be :</p>
<p dir="auto">SEARCH <strong><code>&amp;|(\x20)(?=[^&amp;]*?#)|#</code></strong></p>
<p dir="auto">REPLACE <strong><code>?1_:"</code></strong></p>
<p dir="auto">Of course, assuming this text :</p>
<pre><code class="language-diff">&amp;    C:\xxx\name with spaces.txt    #
</code></pre>
<p dir="auto">Then, the <strong>leading</strong> and <strong>trailing</strong> spaces, around the <strong>absolute</strong> paths, would <strong>not</strong> be deleted anymore but just <strong>replaced</strong> with <strong><code>_</code></strong> characters. Thus, the <strong>final</strong> text would be :</p>
<pre><code class="language-diff">"____C:\xxx\name_with_spaces.txt____"
</code></pre>
<p dir="auto">Best regards,</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/55141</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/55141</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Thu, 02 Jul 2020 14:07:16 GMT</pubDate></item><item><title><![CDATA[Reply to HELP! Replace spaces in text ONLY between quotes? on Wed, 17 Jun 2020 12:24:25 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/195">@guy038</a> said in <a href="/post/55031">HELP! Replace spaces in text ONLY between quotes?</a>:</p>
<blockquote>
<p dir="auto">Alan, do you find this replacement more acceptable ?</p>
</blockquote>
<p dir="auto">I didn’t really mean to “downgrade” the original solution.<br />
It probably helped the OP.<br />
I was just disappointed that it “went too far” so that the general problem solution (that we are now discussing) may have been obscured in the special-purpose result.<br />
But…we’re on the right track now. :-)</p>
]]></description><link>https://community.notepad-plus-plus.org/post/55041</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/55041</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Wed, 17 Jun 2020 12:24:25 GMT</pubDate></item><item><title><![CDATA[Reply to HELP! Replace spaces in text ONLY between quotes? on Tue, 16 Jun 2020 23:03:22 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/195">@guy038</a> said in <a href="/post/55031">HELP! Replace spaces in text ONLY between quotes?</a>:</p>
<blockquote>
<p dir="auto">But, of course, we would assume that…</p>
</blockquote>
<p dir="auto">Yes, those two assumption points are fine!</p>
<p dir="auto">One thing I forgot to mention earlier is that perhaps <em>text1</em>, <em>text2</em>, <em>delimiter1</em> and <em>delimiter2</em> could all be multiple-characters in length (maybe not so obvious for the delimiters?)</p>
]]></description><link>https://community.notepad-plus-plus.org/post/55032</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/55032</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Tue, 16 Jun 2020 23:03:22 GMT</pubDate></item><item><title><![CDATA[Reply to HELP! Replace spaces in text ONLY between quotes? on Tue, 16 Jun 2020 22:47:13 GMT]]></title><description><![CDATA[<p dir="auto">Hi, <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/15302">@mugsys-rapSheet</a>, <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/7377">@alan-kilborn</a> and <strong>All</strong>,</p>
<p dir="auto">First, I’m just adapting my <strong>previous</strong> regex S/R to <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/15302">@mugsys-rapSheet</a> needs, which concern <strong>absolute /relative</strong> paths to files :</p>
<ul>
<li>
<p dir="auto">Now, each <strong>single space</strong> char is replaced with a <strong>single</strong> <strong><code>_</code></strong> char ( instead of <strong>several</strong> spaces into <strong><code>1</code></strong> <strong>underscore</strong> )</p>
</li>
<li>
<p dir="auto">As a filename can contain <strong>leading</strong> spaces <strong>only</strong> and, as an <strong>absolute</strong> path, obviously <strong>cannot</strong> begin with <strong><code>space</code></strong> characters</p>
</li>
</ul>
<p dir="auto">This leads to this <strong>regex</strong> S/R :</p>
<p dir="auto">SEARCH <strong><code>(?-s)([^"#\r\n]*")(?:\x20*(?=\u:))?|\x20*(#)|(\x20)(?=.+#)</code></strong></p>
<p dir="auto">REPLACE <strong><code>(?1\1)(?2")(?3_)</code></strong></p>
<p dir="auto">So from an <strong>initial</strong> text :</p>
<pre><code class="language-diff">A test to "    C:\aaa      zzz\     file with    spaces  .txt     #  verify the regex   "    C:\aaa      zzz\     file with    spaces  .txt     #    behavior

A test to "     file with    spaces  .txt     #  verify the regex   "     file with    spaces  .txt     #    behavior
</code></pre>
<p dir="auto">we would end with :</p>
<pre><code class="language-diff">A test to "C:\aaa______zzz\_____file_with____spaces__.txt"  verify the regex   "C:\aaa______zzz\_____file_with____spaces__.txt"    behavior

A test to "_____file_with____spaces__.txt"  verify the regex   "_____file_with____spaces__.txt"    behavior
</code></pre>
<p dir="auto"><strong>Alan</strong>, do you find this replacement more <strong>acceptable</strong> ?</p>
<hr />
<p dir="auto">Now, regarding the regex <strong>challenge</strong>, I don’t think that <strong>multi</strong>-lines search, with the <strong><code>(?s)</code></strong> <strong>modifier</strong>, would be a problem !</p>
<p dir="auto">But, of course, we would assume that :</p>
<ul>
<li>
<p dir="auto">Any range with <strong>identical</strong> opening and ending delimiter ( mostly the <strong><code>'</code></strong> and <strong><code>"</code></strong> characters ) would have been <strong>previously</strong> changed into an <strong>oriented</strong> range, like, for instance, <strong><code>".........#</code></strong> and <strong><code>'.........#</code></strong> !</p>
</li>
<li>
<p dir="auto">The search would not <strong>simultaneously</strong> search for <strong>two</strong> or <strong>more</strong> ranges ( for instance, ranges <strong><code>".........#</code></strong>  and <strong><code>{..........}</code></strong> ) Too <strong>tricky</strong> ;-))</p>
</li>
</ul>
<p dir="auto">Let me get to the <strong>bottom</strong> of this ;-)) I just hope not to be <strong>long</strong> !</p>
<p dir="auto">Best regards,</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/55031</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/55031</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Tue, 16 Jun 2020 22:47:13 GMT</pubDate></item><item><title><![CDATA[Reply to HELP! Replace spaces in text ONLY between quotes? on Tue, 16 Jun 2020 20:25:30 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/195">@guy038</a></p>
<p dir="auto">How about “Replace <em>text1</em> with <em>text2</em> only between <em>delimiter1</em> and <em>delimiter2</em>”, where delimiter1 and delimiter2 could be the same.</p>
<p dir="auto">No other assumptions.  Meaning, for one thing, that the data doesn’t have to all be on one line.</p>
<p dir="auto">Maybe that is too much for regex?<br />
(Oooh, a challenge for regex…)</p>
]]></description><link>https://community.notepad-plus-plus.org/post/55028</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/55028</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Tue, 16 Jun 2020 20:25:30 GMT</pubDate></item><item><title><![CDATA[Reply to HELP! Replace spaces in text ONLY between quotes? on Tue, 16 Jun 2020 18:23:39 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/195">@guy038</a> ,</p>
<p dir="auto">I see the same behavior on Win10 command (with quotes around the spaces, the leading spaces are preserved, but trailing spaces are eliminated)</p>
]]></description><link>https://community.notepad-plus-plus.org/post/55023</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/55023</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Tue, 16 Jun 2020 18:23:39 GMT</pubDate></item><item><title><![CDATA[Reply to HELP! Replace spaces in text ONLY between quotes? on Tue, 16 Jun 2020 17:28:16 GMT]]></title><description><![CDATA[<p dir="auto">Hi, <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/15302">@mugsys-rapSheet</a>, <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/3841">@Peterjones</a>, @alan-kilbron and <strong>All</strong>,</p>
<p dir="auto">Well <strong>Alan</strong>, I just built up the regex <strong>that</strong> way, because it seems to be the <strong>default Windows</strong> rename behavior ;-) Indeed, on my <strong><code>Win XP</code></strong> laptop, if I try to <strong>rename</strong>, for instance, the <strong><code>Test.txt</code></strong> file, hitting the <strong><code>F2</code></strong> key, into <strong><code>" Test.txt   "</code></strong>, Windows does <strong>not</strong> allow this name <strong>change</strong> !</p>
<p dir="auto">Now, I realized that, in a <strong><code>DOS</code></strong> <strong>console</strong> window, the command :</p>
<pre><code class="language-diff">dir &gt; "   Test.txt   "
</code></pre>
<p dir="auto"><strong>does</strong> create the file :</p>
<pre><code class="language-diff">   Test.txt
</code></pre>
<p dir="auto">with <strong><code>3</code> spaces</strong> before the word <strong>Test</strong>, but <strong>without</strong> any <strong>space</strong> char after the <strong>extension</strong> <strong><code>.txt</code></strong>  !</p>
<p dir="auto">So, could you <strong>verify</strong> on your <strong>newer</strong> Windows OS ? And , of course, an <strong>alternate</strong> regex is <strong>always</strong> possible ;-))</p>
<p dir="auto">BR</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/55019</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/55019</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Tue, 16 Jun 2020 17:28:16 GMT</pubDate></item><item><title><![CDATA[Reply to HELP! Replace spaces in text ONLY between quotes? on Tue, 16 Jun 2020 12:30:12 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/195">@guy038</a> said:</p>
<blockquote>
<p dir="auto">I’ve been thinking about the general problem of doing a replacement, ONLY between zones delimited with…</p>
</blockquote>
<p dir="auto">So this is great.<br />
I started archiving it in my special “notes” file as a general-purpose solution.</p>
<p dir="auto">But…<br />
Then I realized it “goes too far” and perhaps its general-purposeness is destroyed.<br />
I’m talking about the <code>P.S.</code> part above.<br />
I’d have much rather have seen <code>"____C:\xxx\name with spaces.txt____"</code> as the result (keeps the general-purposeness).</p>
<p dir="auto">But…<br />
I’m also curious as to why you would solve a problem that the OP didn’t seem to have.<br />
OP said nothing about leading/trailing spaces needing to be removed.<br />
Of course, the OP was <em>really</em> light on sample data, but…</p>
<p dir="auto">Or am I missing something?</p>
]]></description><link>https://community.notepad-plus-plus.org/post/55010</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/55010</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Tue, 16 Jun 2020 12:30:12 GMT</pubDate></item><item><title><![CDATA[Reply to HELP! Replace spaces in text ONLY between quotes? on Tue, 16 Jun 2020 10:32:27 GMT]]></title><description><![CDATA[<p dir="auto">Hello, @ugsys-rapSheet, <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/3841">@Peterjones</a> and <strong>All</strong>,</p>
<p dir="auto">I’ve been thinking about the <strong>general</strong> problem of doing a <strong>replacement</strong>, <em>ONLY</em> between zones delimited with <strong>double-quotes</strong> ( <strong><code>"......"</code></strong> )</p>
<p dir="auto">The <strong>difficulty</strong> comes from the fact that the <strong><code>2</code></strong> <strong>delimiters</strong> are <strong>identical</strong>. So in order to help, we must, <strong>first</strong>, change, temporarily, the <strong><code>"</code></strong> <strong>ending</strong> delimiter into an <strong>other</strong> character, <strong>not</strong> used yet in <strong>current</strong> file. I chose the <strong><code>#</code></strong> character but any other character, even a <strong>control</strong> char, would be fine if <strong>not</strong> already present in <strong>current</strong> file.</p>
<p dir="auto">So, assuming the <strong>test</strong> sample, below :</p>
<pre><code class="language-diff">    This is a "     C:\aaa zzz \file with spaces" test to verify    if the regex "C:\ aaa zzz\file with spaces.txt    "   works correctly
"     C:\aaa zzz \file with spaces" test to verify    if the regex "C:\ aaa zzz\file with spaces.txt    "   works correctly
This is a "     C:\aaa zzz \file with spaces" test to verify    if the regex "C:\ aaa zzz\file with spaces.txt    "
"     C:\aaa zzz \file with spaces" test to verify    if the regex "C:\ aaa zzz\file with spaces.txt    "

This is a "     file with spaces" test to verify    if the regex "file with spaces.txt    "   works correctly        
"     file with spaces" test to verify    if the regex "file with spaces.txt    "   works correctly
This is a "     file with spaces" test to verify    if the regex "file with spaces.txt    "
"     file with spaces" test to verify    if the regex "file with spaces.txt    "

This is a "     C:\aaa zzz \file with spaces" test to verify    if the regex "C:\ aaa zzz\file with spaces.txt    "   works correctly
</code></pre>
<p dir="auto">The <strong>first</strong> regex S/R is, obviously :</p>
<p dir="auto">SEARCH <strong><code>"(.+?)"</code></strong></p>
<p dir="auto">REPLACE <strong><code>"\1#</code></strong></p>
<p dir="auto">And we would end with :</p>
<pre><code class="language-diff">    This is a "     C:\aaa zzz \file with spaces# test to verify    if the regex "C:\ aaa zzz\file with spaces.txt    #   works correctly
"     C:\aaa zzz \file with spaces# test to verify    if the regex "C:\ aaa zzz\file with spaces.txt    #   works correctly
This is a "     C:\aaa zzz \file with spaces# test to verify    if the regex "C:\ aaa zzz\file with spaces.txt    #
"     C:\aaa zzz \file with spaces# test to verify    if the regex "C:\ aaa zzz\file with spaces.txt    #

This is a "     file with spaces# test to verify    if the regex "file with spaces.txt    #   works correctly        
"     file with spaces# test to verify    if the regex "file with spaces.txt    #   works correctly
This is a "     file with spaces# test to verify    if the regex "file with spaces.txt    #
"     file with spaces# test to verify    if the regex "file with spaces.txt    #

This is a "     C:\aaa zzz \file with spaces# test to verify    if the regex "C:\ aaa zzz\file with spaces.txt      works correctly
</code></pre>
<p dir="auto">Now, here is the <strong>regex</strong> S/R, which changes any <strong><code>space</code></strong> char into an <strong>underscore</strong> character ( <strong><code>_</code></strong> ) in zones <strong><code>".......#</code></strong>  and which changes, back, the <strong>temporary</strong> <strong><code>#</code></strong> character into the usual <strong>double-quote</strong> ( <strong><code>"</code></strong> ) :</p>
<p dir="auto">SEARCH <strong><code>(?-s)([^"#\r\n]*")\x20*|\x20*(#)|(\x20)+(?=.+#)</code></strong></p>
<p dir="auto">REPLACE <strong><code>(?1\1)(?2")(?3_)</code></strong></p>
<p dir="auto">We get our <strong>expected</strong> text :</p>
<pre><code class="language-diff">    This is a "C:\aaa_zzz_\fil_with_spaces" test to verify    if the regex "C:\_aaa_zzz\file_with_spaces.txt"   works correctly
"C:\aaa_zzz_\fil_with_spaces" test to verify    if the regex "C:\_aaa_zzz\file_with_spaces.txt"   works correctly
This is a "C:\aaa_zzz_\fil_with_spaces" test to verify    if the regex "C:\_aaa_zzz\file_with_spaces.txt"
"C:\aaa_zzz_\fil_with_spaces" test to verify    if the regex "C:\_aaa_zzz\file_with_spaces.txt"

This is a "fil_with_spaces" test to verify    if the regex "file_with_spaces.txt"   works correctly        
"fil_with_spaces" test to verify    if the regex "file_with_spaces.txt"   works correctly
This is a "fil_with_spaces" test to verify    if the regex "file_with_spaces.txt"
"fil_with_spaces" test to verify    if the regex "file_with_spaces.txt"

This is a "C:\aaa_zzz_\fil_with_spaces" test to verify    if the regex "C:\ aaa zzz\file with spaces.txt      works correctly
</code></pre>
<p dir="auto">Note that, in the <strong>last</strong> test line, the last <strong><code>#</code></strong> <strong>ending</strong> delimiter is <strong>missing</strong>. So, <strong>all</strong> <strong><code>space</code></strong> chars ,after the <strong>last unpaired</strong> <strong><code>"</code></strong> character, are obviously <strong>not</strong> modified !</p>
<p dir="auto">Best Regards</p>
<p dir="auto">guy038</p>
<p dir="auto"><strong>P.S.</strong> :</p>
<p dir="auto">As, when a file is renamed, any <strong>leading</strong> or <strong>ending</strong> <strong><code>space</code></strong> char, after the <strong>extension</strong>,  are <strong>omitted</strong> from the <strong>final</strong> name, then the regex changes the text :</p>
<pre><code class="language-diff">"    C:\xxx\name with spaces.txt    "
</code></pre>
<p dir="auto">as :</p>
<pre><code class="language-diff">"C:\xxx\name_with_spaces.txt"
</code></pre>
]]></description><link>https://community.notepad-plus-plus.org/post/55006</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/55006</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Tue, 16 Jun 2020 10:32:27 GMT</pubDate></item><item><title><![CDATA[Reply to HELP! Replace spaces in text ONLY between quotes? on Mon, 15 Jun 2020 21:06:10 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/3841">@PeterJones</a> (Quick clarification for anyone reading this is the future:</p>
<p dir="auto">"folderA/folderB/“file name with spaces”;</p>
<p dir="auto">Should be:</p>
<p dir="auto">"folderA/folderB/file name with spaces”;</p>
<p dir="auto">(The extra quote was a typing mistake.)</p>
]]></description><link>https://community.notepad-plus-plus.org/post/54993</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/54993</guid><dc:creator><![CDATA[Mugsys RapSheet]]></dc:creator><pubDate>Mon, 15 Jun 2020 21:06:10 GMT</pubDate></item><item><title><![CDATA[Reply to HELP! Replace spaces in text ONLY between quotes? on Mon, 15 Jun 2020 20:37:53 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/15302">@Mugsys-RapSheet</a> ,</p>
<p dir="auto">Glad it worked.</p>
<p dir="auto">As I said in my italics, using the <code>&lt;/&gt;</code> button on the editing toolbar would have formatted your text <em>as</em> text, so that the quotes wouldn’t turn into <code>“</code>smart quotes<code>”</code> and spaces would be preserved:</p>
<pre><code>codeblock_a {
     .nodename "file_name_with_spaces";
     .filepath "folderA/folderB/"file_name_with_spaces";
}
</code></pre>
<p dir="auto">if there is every the possibility of more than one filename on a line, the regex won’t work.  if that’s true for you, feel free to ask for more clarification.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/54992</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/54992</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Mon, 15 Jun 2020 20:37:53 GMT</pubDate></item><item><title><![CDATA[Reply to HELP! Replace spaces in text ONLY between quotes? on Mon, 15 Jun 2020 20:29:45 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/3841">@PeterJones</a> (Oops, never mind. I forgot to check the “Regular Expression” box.)</p>
<p dir="auto">Worked great. HUGE thanks! You saved me days of tedious work!</p>
]]></description><link>https://community.notepad-plus-plus.org/post/54989</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/54989</guid><dc:creator><![CDATA[Mugsys RapSheet]]></dc:creator><pubDate>Mon, 15 Jun 2020 20:29:45 GMT</pubDate></item><item><title><![CDATA[Reply to HELP! Replace spaces in text ONLY between quotes? on Mon, 15 Jun 2020 20:23:19 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/3841">@PeterJones</a> said in <a href="/post/54984">HELP! Replace spaces in text ONLY between quotes?</a>:</p>
<blockquote>
<p dir="auto">[…]</p>
</blockquote>
<p dir="auto">Thanks for the reply. I don’t understand the syntax for using that in a search (a simple copy/paste of the text in pink didn’t work.)</p>
<p dir="auto">Here is an example code block:</p>
<p dir="auto">codeblock_a {<br />
-----.nodename “file name with spaces”;<br />
-----.filepath "folderA/folderB/“file name with spaces”;<br />
}</p>
<p dir="auto">Thx. (hyphens are spaces.)</p>
]]></description><link>https://community.notepad-plus-plus.org/post/54988</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/54988</guid><dc:creator><![CDATA[Mugsys RapSheet]]></dc:creator><pubDate>Mon, 15 Jun 2020 20:23:19 GMT</pubDate></item><item><title><![CDATA[Reply to HELP! Replace spaces in text ONLY between quotes? on Mon, 15 Jun 2020 19:54:50 GMT]]></title><description><![CDATA[<p dir="auto">Based on the vague specs you gave, a vague answer might be</p>
<p dir="auto">Given the data</p>
<pre><code>blah blah blah
blah "file with space" blah
blah
"space file"
blah
not a file
</code></pre>
<ul>
<li>FIND = <code>(?-s)("\S+)\h(?=.*?")</code></li>
<li>REPLACE = <code>${1}_</code></li>
<li>mode = regular expression</li>
<li>then hit <strong>REPLACE</strong> or <strong>REPLACE ALL</strong> multiple times until everything is replaced.
<ul>
<li>If you use <strong>Replace</strong>, you will need to hit it once for every space in a filename in your script</li>
<li>if you use <strong>Replace All</strong>, you should only need to hit it once per space for the filename with the maximum spaces</li>
</ul>
</li>
</ul>
<p dir="auto">Note that this assumes that you only have one quoted filename per line.  If it’s more than that, the logic becomes exceedingly convoluted.</p>
<p dir="auto">If you were able to give example data (if there is sensitive info, just use dummy words), which gave a good indication of the structure – whether there are any other rules that could help us narrow down the regex so it will have fewer false matches – that would be great.</p>
<p dir="auto">----</p>
<p dir="auto"><em>Do you want regex search/replace help?  Then please be patient and polite, show some effort, and be willing to learn; answer questions and requests for clarification that are made of you.  All example text should be marked as plain text using the <code>&lt;/&gt;</code> toolbar button or manual <a href="https://community.notepad-plus-plus.org/topic/14262/how-to-markdown-code-on-this-forum/4">Markdown syntax</a>. Screenshots can be pasted from the clipbpard to your post using <code>Ctrl+V</code> to show graphical items, but any text should be included as literal text in your post so we can easily copy/paste your data. Show the data you have <strong>and</strong> the text you want to get from that data; include examples of things that <strong>should match</strong> and be transformed, <strong>and</strong> things that <strong>don’t match</strong> and should be left alone; show <strong>edge cases</strong> and make sure you examples are as <strong>varied</strong> as your real data.  Show the regex you already tried, <strong>and why</strong> you thought it should work; tell us what’s wrong with what you <strong>do</strong> get… Read the official <a href="https://npp-user-manual.org/docs/searching/#regular-expressions" rel="nofollow ugc">NPP Searching / Regex docs</a> and the forum’s <a href="https://community.notepad-plus-plus.org/topic/15765/faq-desk-where-to-find-regex-documentation">Regular Expression FAQ</a>. If you follow these guidelines, you’re much more likely to get helpful replies that solve your problem in the shortest number of tries.</em></p>
]]></description><link>https://community.notepad-plus-plus.org/post/54984</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/54984</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Mon, 15 Jun 2020 19:54:50 GMT</pubDate></item></channel></rss>