<?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[Changing Data inside XML element]]></title><description><![CDATA[<p dir="auto">Have this as an example:</p>
<p dir="auto">&lt;ProductName&gt;&lt;![CDATA[Product Name Could be anything here L/XL&rsqb;&rsqb;&gt;&lt;/ProductName&gt;<br />
&lt;ProductName&gt;&lt;![CDATA[Product Name Could be anything here S/XXL&rsqb;&rsqb;&gt;&lt;/ProductName&gt;</p>
<p dir="auto"></p><div class="plugin-markdown"><input type="checkbox" />and only replace the “/” for the &lt;ProductName&gt;.</div><p></p>
<p dir="auto">How can I do a find and replace on the “/” to a “-” so that it will not course me issues in another process, please?</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/20728/changing-data-inside-xml-element</link><generator>RSS for Node</generator><lastBuildDate>Sat, 18 Jul 2026 13:04:23 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/20728.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 11 Feb 2021 11:40:39 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Changing Data inside XML element on Wed, 24 Feb 2021 00:08:01 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/63168">Changing Data inside XML element</a>:</p>
<blockquote>
<p dir="auto">See, also, an interesting helping post, of <a class="plugin-mentions-user plugin-mentions-a" href="/user/arkadiuszmichalski" aria-label="Profile: ArkadiuszMichalski">@<bdi>ArkadiuszMichalski</bdi></a>, regarding how to test new N++ builds !<br />
<a href="https://github.com/notepad-plus-plus/notepad-plus-plus/issues/9493#issuecomment-781344297" rel="nofollow ugc">https://github.com/notepad-plus-plus/notepad-plus-plus/issues/9493#issuecomment-781344297</a></p>
</blockquote>
<p dir="auto">Seems to be official now:</p>
<p dir="auto"><a href="https://github.com/notepad-plus-plus/notepad-plus-plus/wiki/Testing" rel="nofollow ugc">https://github.com/notepad-plus-plus/notepad-plus-plus/wiki/Testing</a></p>
<p dir="auto">Good job <a class="plugin-mentions-user plugin-mentions-a" href="/user/arkadiuszmichalski" aria-label="Profile: ArkadiuszMichalski">@<bdi>ArkadiuszMichalski</bdi></a> !</p>
<p dir="auto">Cheers.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/63169</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/63169</guid><dc:creator><![CDATA[Michael Vincent]]></dc:creator><pubDate>Wed, 24 Feb 2021 00:08:01 GMT</pubDate></item><item><title><![CDATA[Reply to Changing Data inside XML element on Tue, 23 Feb 2021 23:31:49 GMT]]></title><description><![CDATA[<p dir="auto">Hi, <strong>All</strong>,</p>
<p dir="auto">See my results of testing the <a class="plugin-mentions-user plugin-mentions-a" href="/user/sasumner" aria-label="Profile: sasumner">@<bdi>sasumner</bdi></a>’s build, about the <strong><code>\K</code></strong> <strong>assertion</strong> and the <strong><code>step by step</code></strong> replacement :</p>
<p dir="auto"><a href="https://github.com/notepad-plus-plus/notepad-plus-plus/issues/8434#issuecomment-784583153" rel="nofollow ugc">https://github.com/notepad-plus-plus/notepad-plus-plus/issues/8434#issuecomment-784583153</a></p>
<p dir="auto">See, also, an <strong>interesting</strong> helping post, of <a class="plugin-mentions-user plugin-mentions-a" href="/user/arkadiuszmichalski" aria-label="Profile: ArkadiuszMichalski">@<bdi>ArkadiuszMichalski</bdi></a>, regarding how to test <strong>new</strong> N++ <strong>builds</strong> !</p>
<p dir="auto"><a href="https://github.com/notepad-plus-plus/notepad-plus-plus/issues/9493#issuecomment-781344297" rel="nofollow ugc">https://github.com/notepad-plus-plus/notepad-plus-plus/issues/9493#issuecomment-781344297</a></p>
<p dir="auto">Best Regards,</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/63168</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/63168</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Tue, 23 Feb 2021 23:31:49 GMT</pubDate></item><item><title><![CDATA[Reply to Changing Data inside XML element on Tue, 23 Feb 2021 11:55:07 GMT]]></title><description><![CDATA[<p dir="auto">Hello, <a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: alan-kilborn">@<bdi>alan-kilborn</bdi></a> and <strong>All</strong>,</p>
<p dir="auto"><strong>Alan</strong>, I did <strong>numerous</strong> tests and, I’m <strong>afraid</strong>, that all that story does <strong>not</strong> depend on the <strong><code>\G</code></strong> assertion, anyway but <strong>only</strong> on the <strong><code>\K</code></strong> one !! Yes, really not <strong>easy</strong> :-((</p>
<p dir="auto">So here is, below, <strong>how</strong> I imagine the process, <strong>after</strong> clicking, either, on the <strong><code>Find Next</code></strong> or the <strong><code>Replace</code></strong> of the <strong>Replace</strong> dialog, whatever the search <strong>mode</strong>. Note that we will <strong>not</strong> speak about the <strong><code>Replace All</code></strong> behavior, at all !</p>
<hr />
<p dir="auto">After <strong>any</strong> click on the <strong><code>Find Next</code></strong> button, the regex engine <strong>starts</strong> searching for a <strong>match</strong> of the <strong>search</strong> regex :</p>
<ul>
<li>
<p dir="auto">From the <strong><code>end</code></strong> of a <strong>present</strong> normal <strong>selection</strong></p>
</li>
<li>
<p dir="auto">From the <strong>present</strong> position of the caret, if <strong><code>NO</code></strong> selection exists</p>
</li>
</ul>
<p dir="auto">Then :</p>
<ul>
<li>
<p dir="auto"><em>IF</em> <strong><code>NO</code></strong> match exists, the overall process <strong>stops</strong></p>
</li>
<li>
<p dir="auto"><em>IF</em> a match has been <strong>found</strong>, it is <strong>selected</strong></p>
</li>
</ul>
<hr />
<p dir="auto">After <strong>any</strong> click on the <strong><code>Replace</code></strong> button, the regex engine <strong>starts</strong> searching for a <strong>match</strong> of the <strong>search</strong> regex :</p>
<ul>
<li>
<p dir="auto">From the <strong><code>start</code></strong> of a <strong>present</strong> normal <strong>selection</strong></p>
</li>
<li>
<p dir="auto">From the <strong>present</strong> position of the caret, if <strong><code>NO</code></strong> selection exists</p>
</li>
</ul>
<p dir="auto">Then :</p>
<ul>
<li>
<p dir="auto"><em>IF</em> <strong><code>NO</code></strong> match exists, the overall process <strong>stops</strong></p>
</li>
<li>
<p dir="auto"><em>IF</em> a match has been <strong>found</strong> :</p>
<ul>
<li>
<p dir="auto"><em>IF</em> the match is <strong><code>strictly identical</code></strong> to the <strong>previous</strong> selection :</p>
<ul>
<li>
<p dir="auto">The <strong>selection/match</strong> is <strong><code>replaced</code></strong> with the replacement <strong>regex</strong></p>
</li>
<li>
<p dir="auto">The current position is <strong>reset</strong> to the location, right after the <strong><code>end</code></strong> of the <strong>replacement</strong> regex</p>
</li>
<li>
<p dir="auto">And the regex engine <strong>re</strong>-starts searching, further on, for a <strong><code>next</code></strong> match of the <strong>search</strong> regex :</p>
<ul>
<li>
<p dir="auto"><em>IF</em> such a <strong>match</strong> can be found, it is <strong>selected</strong></p>
</li>
<li>
<p dir="auto"><em>IF</em> <strong><code>NO</code></strong> match exists, the overall process <strong>stops</strong></p>
</li>
</ul>
</li>
</ul>
</li>
<li>
<p dir="auto"><em>IF</em> the match is <strong><code>different</code></strong> from the <strong>previous</strong> selection <em>OR IF</em> <strong><code>no</code> previous</strong> selection exists :</p>
<ul>
<li>This <strong>match</strong> is just <strong>selected</strong>, <strong><code>without</code></strong> any <strong>replacement</strong> process</li>
</ul>
</li>
</ul>
</li>
</ul>
<hr />
<p dir="auto">So, the <strong>complete</strong> solution, in order that the <strong><code>step by step</code></strong> replacement works <strong>correctly</strong>, is that the current <strong>search</strong>, in <strong>any</strong> mode, matches the <strong>previous</strong> selection, whatever the way that <strong>selection</strong> was obtained :</p>
<ul>
<li>
<p dir="auto">By a <strong>previous</strong> click on the <strong><code>Replace</code></strong> button ( <strong>standard</strong> case of <strong>subsequent</strong> replacements )</p>
</li>
<li>
<p dir="auto">By a <strong>previous</strong> click on the <strong><code>Find Next</code></strong> button ( <strong>standard</strong> case of a <strong>first</strong> replacement )</p>
</li>
<li>
<p dir="auto">By a <strong>manual</strong> selection or move of the <strong>caret</strong>, generated <strong>intentionally</strong>, by the <strong>user</strong> !</p>
</li>
</ul>
<p dir="auto">Thus :</p>
<ul>
<li>In case of a search, in the <strong><code>Normal</code></strong> or <strong><code>Extended</code></strong> mode OR if <strong>no</strong> <strong><code>\K</code></strong> assertion is used, in <strong><code>Regex</code></strong> mode :</li>
</ul>
<p dir="auto">=&gt; The <strong>previous</strong> selection, <strong>generated</strong> by a click on the <strong><code>Find Next</code></strong> or <strong><code>Replace</code></strong> button AND the <strong>present</strong> match, met at the <strong>start</strong> of the selection, are <strong>always</strong> identical, meaning that the <strong><code>Step by Step</code></strong> replacement feature is <strong>always</strong> functional !</p>
<ul>
<li>In the case of the <strong>particular</strong> use of the <strong><code>\K</code></strong> assertion, in <strong><code>Regex</code></strong> mode, the <strong>present</strong> selection, <strong>before</strong> clicking on the <strong><code>Replace</code></strong> button, is the part of the regex, located <strong>after</strong> <strong><code>\K</code></strong> structure. So the <strong>rule</strong> is :</li>
</ul>
<p dir="auto">=&gt; A simple <strong>replacement</strong> can occur <em>ONLY IF</em> the <strong>overall</strong> regex can <strong>match</strong> the part of the regex located <strong>after</strong> the <strong><code>\K</code></strong> syntax !</p>
<p dir="auto">In other words, if we consider the <strong>general</strong> regex form <strong><code>........\K••••••••</code></strong>, this means that :</p>
<p dir="auto">The <strong>overall</strong> regex <strong><code>........\K••••••••</code></strong> <strong>must</strong> match, <strong>exactly</strong>, the <strong>same</strong> expression than the <strong><code>••••••••</code></strong> <strong>sub</strong>-regex</p>
<hr />
<p dir="auto">For instance :</p>
<ul>
<li>
<p dir="auto"><strong>(A)</strong> The regex <strong><code>(?-s).*?\Kabc</code></strong> does match the <strong>sub</strong>-regex <strong><code>abc</code></strong>, after <strong><code>\K</code></strong> =&gt; The <strong>step-by-step</strong> replacement is possible</p>
</li>
<li>
<p dir="auto"><strong>(B)</strong> Similarly, the regex <strong><code>(?-s).*?\Kabc\d</code></strong> does match the <strong>sub</strong>-regex <strong><code>abc\d</code></strong>, after <strong><code>\K</code></strong> =&gt; The <strong>step-by-step</strong> replacement is <strong>OK</strong></p>
</li>
<li>
<p dir="auto"><strong>(C)</strong> And the regex <strong><code>(?-s).*?\K\dabc</code></strong> does match the <strong>sub</strong>-regex <strong><code>\dabc</code></strong>, after <strong><code>\K</code></strong> =&gt; The <strong>step-by-step</strong> replacement will work</p>
</li>
</ul>
<p dir="auto"><strong>But</strong>, on the <strong>contrary</strong> :</p>
<ul>
<li>
<p dir="auto"><strong>(D)</strong> The regex <strong><code>(?-s)\d.*?\Kabc</code></strong> does <strong>not</strong> match the <strong>sub</strong>-regex <strong><code>abc</code></strong>, after <strong><code>\K</code></strong> =&gt; The <strong>step-by-step</strong> replacement is <strong>not</strong> possible</p>
</li>
<li>
<p dir="auto"><strong>(E)</strong> Similarly, the regex <strong><code>(?-s)\d.*?\K\dabc</code></strong> does <strong>not</strong> match the <strong>sub</strong>-regex <strong><code>\dabc</code></strong>, after <strong><code>\K</code></strong> =&gt; The <strong>step-by-step</strong> replacement is <strong>KO</strong></p>
</li>
<li>
<p dir="auto">(<strong>F)</strong> Now, the regex <strong><code>(?-s)\d.*?\K\d?abc</code></strong> <strong>never</strong> matches the <strong>sub</strong>-regex <strong><code>\d?abc</code></strong>, after <strong><code>\K</code></strong>, too =&gt; The <strong>step-by-step</strong> replacement will <strong>not</strong> work. However, by clicking <strong>successively</strong> on the <strong><code>Replace</code></strong> button, it produces :</p>
<ul>
<li>
<p dir="auto"><strong>Firstly</strong>, a selection of the <strong><code>\dabc</code></strong> string, if that string is preceded, <strong>itself</strong>, with a <strong>digit</strong></p>
</li>
<li>
<p dir="auto"><strong>Secondly</strong>, a selection of the <strong><code>abc</code></strong> string</p>
</li>
</ul>
</li>
<li>
<p dir="auto"><strong>(G)</strong> Note that the use of the regex <strong><code>(?-s)\d?.*?\K\d?abc</code></strong>, is more <strong>difficult</strong> to understand, although logical : by clicking <strong>successively</strong> on the <strong><code>Replace</code></strong> button, it produces, <strong>either</strong> :</p>
<ul>
<li>
<p dir="auto">A selection of <strong><code>abc</code></strong>, if the <strong>previous</strong> selection was <strong><code>\dabc</code></strong></p>
</li>
<li>
<p dir="auto">A replacement by the <strong><code>@</code></strong> symbol, if the <strong>previous</strong> selection was <strong><code>abc</code></strong></p>
</li>
</ul>
</li>
<li>
<p dir="auto"><strong>(H)</strong> To end with, remark that, making the <strong>first</strong> <strong><code>\d?</code></strong> expression <strong>lazy</strong>, the resulting regex <strong><code>(?-s)\d??.*?\K\d?abc</code></strong> does <strong>match</strong> the <strong>sub</strong>-regex <strong><code>\d?abc</code></strong>, after <strong><code>\K</code></strong>. So :</p>
<ul>
<li>
<p dir="auto">The <strong>step-by-step</strong> replacement works <strong>nice</strong></p>
</li>
<li>
<p dir="auto">Any click on the <strong><code>Replace</code></strong> button, from the <strong>second</strong>, does change the <strong>matched</strong> string <strong><code>\dabc</code></strong> into a <strong><code>@</code></strong> symbol</p>
</li>
</ul>
</li>
</ul>
<hr />
<ul>
<li>
<p dir="auto"><strong>Test</strong> all these regexes, above, against the <strong>text</strong> <strong><code>123abc456abc0abc789abc0</code></strong>, pasted in a <strong>new</strong> tab</p>
</li>
<li>
<p dir="auto">The <strong>Replace</strong> regex is just <strong><code>@</code></strong>, in <strong>all</strong> cases</p>
</li>
<li>
<p dir="auto">Select the <strong><code>Regular expression</code></strong> search <strong>mode</strong></p>
</li>
<li>
<p dir="auto">Click <strong>only</strong> on the <strong><code>Replace</code></strong> or <strong><code>Find Next</code></strong> button ( Do <strong>not</strong> use the <strong><code>Replace All</code></strong> button )</p>
</li>
</ul>
<hr />
<p dir="auto"><strong>Alan</strong>, the <strong>crucial</strong> point is to <strong>move</strong> the <strong>caret</strong> or <strong>create</strong> a normal <strong>selection</strong>, <em>by yourself</em>, <strong>before</strong> one or some  click(s) on the <strong><code>Replace</code></strong> button, and observe the results with the hope of deducing a <strong>logical</strong> behavior, as I did ! This will allow you to <strong>confirm</strong> or <strong>deny</strong> my assertions ;-))</p>
<p dir="auto">Best Regards,</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/63087</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/63087</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Tue, 23 Feb 2021 11:55:07 GMT</pubDate></item><item><title><![CDATA[Reply to Changing Data inside XML element on Fri, 19 Feb 2021 22:07:33 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></p>
<p dir="auto">So this is all very confusing until one breaks it down! :-)<br />
And even then it is still confusing. :-(</p>
<p dir="auto">Following your steps:</p>
<blockquote>
<p dir="auto">Now, in this new tab, containing the sample text :<br />
Move back to the beginning ( Ctrl + Home )<br />
Open the Replace dialog Ctrl + H )<br />
SEARCH (?-s)(abc|(?!\A)\G).*?\K\x20<br />
REPLACE @<br />
Click once on the Replace button ( identical to a click on the Find Next button ! )</p>
</blockquote>
<p dir="auto">Then, without doing anything else (without pressing any more buttons), you say:</p>
<blockquote>
<p dir="auto">Thus, the regex engine uses, necessarily, the first alternative ( the regex (?-s)abc.<em>?\K\x20 ), which indeed, contains a part, before \K, <strong>which is not a zero-length area</strong>, as equal to (?-s)abc.</em>?</p>
</blockquote>
<p dir="auto">Which I wholly agree with.</p>
<p dir="auto">But… the point where I talked (in my previous post) about a zero-length string to the left of \K has not come into play (yet)!</p>
<p dir="auto">We are left sitting and looking at:</p>
<p dir="auto"><img src="/assets/uploads/files/1613770154634-82432183-357f-4e78-8cf7-0b5f27fa1cdd-image.png" alt="82432183-357f-4e78-8cf7-0b5f27fa1cdd-image.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">Note the single space selected in line 5.</p>
<p dir="auto">At this point <em>Replace</em> is pressed a second time.<br />
The internal find is again run and the match that occurs is going to effectively be this part of the regex:</p>
<p dir="auto"><code>(?!\A)\G.*?\K\x20</code></p>
<p dir="auto">and that <em><strong>IS</strong></em> going to be zero-length to the left of the <code>\K</code> !</p>
<p dir="auto">The key point might be that <code>\G</code> will match because it by definition “matches at the start of string-to-search at the first attempt”.  And because this search is indeed a new search, we are AT the first attempt.  The start of the string-to-search is going to be the left side of the selected space character.</p>
<p dir="auto">So in summary, to the left of the <code>\K</code> for the match we have:</p>
<ul>
<li><code>(?!\A)</code> -&gt; match of zero-length</li>
<li><code>\G</code> -&gt; match of zero-length (from “key point” just above)</li>
<li><code>.*?</code> -&gt; match of zero-length (because \x20 will match next and since we are a minimal match, we match zero)</li>
</ul>
<p dir="auto">Add up all those zeroes to obtain: 0+0+0=0</p>
<p dir="auto">And thus my postulate from the previous posting seems to hold: If the match to the left of <code>\K</code> is a zero-length match, the replacement WILL be made.  So in this case the <code>@</code> replaces the space.</p>
<p dir="auto">Any time the <em>Replace</em> button is pressed, it only replaces if the current selection matches the find-expression – do we agree on this?  Regex or not…right?</p>
<p dir="auto">Because <code>\K</code> “cancels out” what comes before it in a regex (and it must cancel it very deeply in the regex engine – because <code>(?&lt;...)</code> doesn’t have the same difficulty <code>\K</code> does), the only way a current selection is going to match an expression using <code>\K</code> is if what is to the left of the <code>\K</code> has no length to it.</p>
<p dir="auto">I’d be happy to have you poke holes in my logic here!  :-)</p>
]]></description><link>https://community.notepad-plus-plus.org/post/63066</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/63066</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Fri, 19 Feb 2021 22:07:33 GMT</pubDate></item><item><title><![CDATA[Reply to Changing Data inside XML element on Fri, 19 Feb 2021 18:38:54 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/63060">Changing Data inside XML element</a>:</p>
<blockquote>
<p dir="auto">Not totally exact, Alan !</p>
</blockquote>
<blockquote>
<p dir="auto">But it just so happens that our generic regex S/R…</p>
</blockquote>
<p dir="auto">Ok, then, back to the drawing board.<br />
More analysis work on this for me!<br />
I’ll return with the answers.<br />
Well…if I find them.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/63061</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/63061</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Fri, 19 Feb 2021 18:38:54 GMT</pubDate></item><item><title><![CDATA[Reply to Changing Data inside XML element on Fri, 19 Feb 2021 18:40:55 GMT]]></title><description><![CDATA[<p dir="auto">Hello, <a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: alan-kilborn">@<bdi>alan-kilborn</bdi></a> and <strong>All</strong>,</p>
<p dir="auto">You said :</p>
<blockquote>
<p dir="auto">If you use \K in a regex, if the part of the regex to the left of the \K matches as zero-length, the Replace button press WILL work to replace data. If, however, the part of the regex to the left of \K matches one or more characters, a press of Replace will NOT perform a textual substitution, but will rather just move to the next higher match.</p>
</blockquote>
<p dir="auto">Not <strong>totally</strong> exact, <strong>Alan</strong> !</p>
<p dir="auto">For instance, let’s imagine this text, in a <strong>new</strong> tab, beginning with <strong>two blank</strong> lines :</p>
<pre><code class="language-z">

78464 13232178913 894654465464 12231

52632abc9526271 026238121 945135 s1658

6479123789 456134 978941 13454

46464646l 4567861341 128978 10313

111386460abc9564 6240 17868913345100544 4867864
</code></pre>
<p dir="auto">Note that the lines <strong><code>5</code></strong> and <strong><code>11</code></strong>, <strong>only</strong>, contains the string <strong><code>abc</code></strong></p>
<hr />
<p dir="auto">And let’s use a simple regex, <strong>derived</strong> from our <strong>generic</strong> regex, presently studied in the <strong>previous</strong> posts :</p>
<p dir="auto"><strong><code>(?-s)(abc|(?!\A)\G).*?\K\x20</code></strong></p>
<p dir="auto">Now, in this <strong>new</strong> tab, containing the <strong>sample</strong> text :</p>
<ul>
<li>
<p dir="auto">Move back to the beginning ( <strong><code>Ctrl + Home</code></strong> )</p>
</li>
<li>
<p dir="auto">Open the <strong>Replace</strong> dialog <strong><code>Ctrl + H</code></strong> )</p>
<ul>
<li>
<p dir="auto">SEARCH <strong><code>(?-s)(abc|(?!\A)\G).*?\K\x20</code></strong></p>
</li>
<li>
<p dir="auto">REPLACE <strong><code>@</code></strong></p>
</li>
</ul>
</li>
<li>
<p dir="auto">Click <strong>once</strong> on the <strong><code>Replace</code></strong> button ( <strong>identical</strong> to a click on the <strong><code>Find Next</code></strong> button ! )</p>
</li>
</ul>
<p dir="auto">=&gt; The <strong>first space</strong> character, of line <strong><code>5</code></strong>, is <strong>matched</strong>. As the caret was initially on a <strong>blank</strong> line, it <strong>cannot</strong> match any <strong>standard</strong> character. So the part <strong><code>(?-s)(?!\A)\G.*?\K\x20</code></strong>, with the <strong>second</strong> alternative, has <strong>not</strong> been used by the regex engine</p>
<p dir="auto">Thus, the regex engine uses, necessarily, the <strong>first</strong> alternative ( the regex <strong><code>(?-s)abc.*?\K\x20</code></strong> ), which indeed, contains a part, before <strong><code>\K</code></strong>, which is not a <strong>zero-length</strong> area, as equal to <strong><code>(?-s)abc.*?</code></strong></p>
<p dir="auto">However, if you click a <strong>second</strong> time on the <strong><code>Replace</code></strong> button, the <strong>first space</strong> char of line <strong><code>5</code></strong> is, as <strong>expected</strong>, changed into the <strong><code>@</code></strong> symbol !</p>
<p dir="auto">Of course, any <strong>further space</strong> char, located in lines containing the <strong><code>abc</code></strong> string, are <strong>replaced</strong>, in the same way, after <strong>successive</strong> clicks on the <strong><code>Replace</code></strong> button</p>
<hr />
<p dir="auto">You also said :</p>
<blockquote>
<p dir="auto">Probably a zero-length match to the left of \K in a regex isn’t very useful often;</p>
</blockquote>
<p dir="auto">But it just so happens that our <strong>generic</strong> regex <strong>S/R</strong> :</p>
<p dir="auto">SEARCH <strong><code>(?s-i:</code>BSR<code>|(?!\A)\G)(?s-i:(?!</code>ESR<code>).)*?\K(?s-i:</code>FR<code>)</code></strong></p>
<p dir="auto">REPLACE <strong><code>RR</code></strong></p>
<p dir="auto">seems to work <strong>correctly</strong> with “<strong>step-by-step</strong>” replacement ;-))</p>
<p dir="auto">Note that the <strong>search</strong> syntax above corresponds to the <strong>particular</strong> case where :</p>
<ul>
<li>
<p dir="auto">The search is <strong>sensible</strong> to the <strong>case</strong> of letters</p>
</li>
<li>
<p dir="auto">The search may <strong>extend</strong> to a <strong>multi-lines</strong> area</p>
</li>
<li>
<p dir="auto"><strong>No</strong> subset of <strong>FR</strong>, is needed in the <strong>replacement</strong> regex  =&gt; All groups are <strong>non-capturing</strong> ones</p>
</li>
</ul>
<p dir="auto">Best Regards,</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/63060</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/63060</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Fri, 19 Feb 2021 18:40:55 GMT</pubDate></item><item><title><![CDATA[Reply to Changing Data inside XML element on Fri, 19 Feb 2021 16:21:43 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></p>
<p dir="auto">So I was intrigued by your \K results, but let me confine my response to just this small part of your posting:</p>
<pre><code class="language-z">(?x-s).+?\K\x20           # KO  ( 3 SPACE chars NOT changed )
(?x-s).*?\K\x20           # OK  ( 3 SPACE chars CHANGED into @ )

abgcd ef ghi j
          1111  &lt;- tens, and
01234567890123  &lt;- ones position in doc
</code></pre>
<p dir="auto">But rather than looking at it as a user and regex guru as you did, I cheated – because I’m not the same guru – and looked at the N++ source code.</p>
<p dir="auto">So, what Notepad++ does, when you click on the <em>Replace</em> button is, it runs its <em>Find Next</em> code search (transparently) and sets a variable called “nextFind”.  This search starts at the minimum position of the current selection (or just the caret position if no selection is active) and proceeds toward higher positions in the doc.</p>
<p dir="auto">If what comes out of that search is a match of the same selected text position range as you began with, then the replacement is made.</p>
<p dir="auto">If what results from the <em>Find Next</em> search is some <em>different</em> text selected (or you had <em>nothing</em> selected originally), the replace is not done, but the new text selection is now the nearest match higher in the doc (presumably convenient for your next press of <em>Replace</em>!).</p>
<p dir="auto">On actual replacement, it then moves the selection to the following match it finds (meaning that internally it runs another <em>Find Next</em>).  For the case where the replacement was made, the following search starts at the very righthand side of the newly inserted text.<br />
That’s kind of a wordy explanation for this part, but hopefully it makes some sense.</p>
<p dir="auto">Okay, so what does this all this mean for regexes using <code>\K</code>, specifically yours above where the first one doesn’t work and the second one does ?</p>
<h3>analysis of “first” regex:</h3>
<p dir="auto"><code>(?x-s).+?\K\x20</code></p>
<p dir="auto">move caret to start-of-file, data as stated above: <code>abgcd ef ghi j</code></p>
<p dir="auto">first press of <em>Replace</em> button:<br />
active selection range at time of button press: (0,0)<br />
code runs at Replace press:<br />
calculates “nextFind” selection range = (5,6)<br />
no (selection range) equivalency to (0,0) so <strong>NOTHING IS REPLACED</strong><br />
selection moves to (5,6) which is the space between <code>d</code> and <code>e</code></p>
<p dir="auto">second press of <em>Replace</em> button:<br />
active selection range at time of button press: (5,6)<br />
code runs at Replace press:<br />
calculates “nextFind” selection range = (8,9)<br />
no (selection range) equivalency to (5,6) so <strong>NOTHING IS REPLACED</strong><br />
selection moves to (8,9) which is the space between <code>f</code> and <code>g</code></p>
<p dir="auto">third press of <em>Replace</em> button:<br />
active selection range at time of button press: (8,9)<br />
code runs at Replace press:<br />
calculates “nextFind” selection range = (12,13)<br />
no (selection range) equivalency to (8,9) so <strong>NOTHING IS REPLACED</strong><br />
selection moves to (12,13) which is the space between <code>i</code> and <code>j</code></p>
<p dir="auto">etc.</p>
<h3>analysis of “second” regex:</h3>
<p dir="auto"><code>(?x-s).*?\K\x20</code></p>
<p dir="auto">move caret to start-of-file, data as stated above: <code>abgcd ef ghi j</code></p>
<p dir="auto">first press of <em>Replace</em> button:<br />
active selection range at time of button press: (0,0)<br />
code runs at Replace press:<br />
calculates “nextFind”  selection range = (5,6)<br />
no (selection range) equivalency to (0,0) so <strong>NOTHING IS REPLACED</strong><br />
selection moves to (5,6) (the space between <code>d</code> and <code>e</code>)</p>
<p dir="auto">second press of <em>Replace</em> button:<br />
active selection range at time of button press: (5,6)<br />
code runs at Replace press:<br />
calculates “nextFind”  selection range = (5,6)<br />
have (selection range) equivalency to (5,6) so <strong>REPLACEMENT IS MADE</strong><br />
selection moves to (8,9) which is the next match between the <code>f</code> and <code>g</code></p>
<p dir="auto">third press of <em>Replace</em> button:<br />
active selection range at time of button press: (8,9)<br />
code runs at Replace press:<br />
calculates “nextFind”  selection range = (8,9)<br />
have (selection range) equivalency to (8,9) so <strong>REPLACEMENT IS MADE</strong><br />
selection moves to (12,13), which is the next match between the <code>i</code> and <code>j</code></p>
<p dir="auto">etc.</p>
<p dir="auto">Here’s the conclusion I draw from this:</p>
<p dir="auto">If you use <code>\K</code> in a regex, if the part of the regex to the left of the <code>\K</code> matches as zero-length, the <em>Replace</em> button press WILL work to replace data.  If, however, the part of the regex to the left of <code>\K</code> matches one or more characters, a press of <em>Replace</em> will NOT perform a textual substitution, but will rather just move to the next higher match.</p>
<p dir="auto">Following this rule: Because the “first” regex demands that a minimum of one character be matched to the left of <code>\K</code>, no <em>Replace</em> ments are made.  Because the “second” regex has a minimum-of-zero requirement, when it does match zero, that match comes to the left of <code>\K</code>, so a <em>Replace</em> is allowed to actually replace.</p>
<p dir="auto">Probably a zero-length match to the left of <code>\K</code> in a regex isn’t very useful often; perhaps that is why I don’t recall hearing of <code>\K</code> and single-step replace “working only sometimes” in the past?  Typically, it is, “doesn’t work”.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/63059</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/63059</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Fri, 19 Feb 2021 16:21:43 GMT</pubDate></item><item><title><![CDATA[Reply to Changing Data inside XML element on Sun, 14 Feb 2021 11:59:43 GMT]]></title><description><![CDATA[<p dir="auto">Hi, <a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: alan-kilborn">@<bdi>alan-kilborn</bdi></a> and <strong>All</strong>,</p>
<p dir="auto">I tried to study the <strong><code>\K</code></strong> behavior, in case of a simple <strong>replacement</strong> with the <strong><code>Replace</code></strong> button and, unfortunately, I <strong>cannot</strong> deduce a <strong>general</strong> rule for that <strong>assertion</strong> :-((</p>
<ul>
<li>
<p dir="auto">Open a <strong>new</strong> tab and <strong>paste</strong> the simple expression <strong><code>abgcd ef ghi j</code></strong></p>
</li>
<li>
<p dir="auto">Select <strong>one</strong> line of the list , below, containing a <strong>regex</strong></p>
</li>
<li>
<p dir="auto">Open the <strong>Replace</strong> dialog( <strong><code>Ctrl + H</code></strong> )</p>
</li>
<li>
<p dir="auto">For <strong>all</strong> the examples, the <strong><code>Replace with</code></strong> field contains only the <strong><code>@</code></strong> character</p>
</li>
<li>
<p dir="auto">Click <strong>once</strong> on the <strong><code>Find Next</code></strong> button</p>
</li>
<li>
<p dir="auto">Then, click <strong>several</strong> times on the <strong><code>Replace</code></strong> button … till <strong>no</strong> replacement occurs</p>
</li>
</ul>
<p dir="auto">=&gt;</p>
<pre><code class="language-z">Results, after :

    - A "CTRL + HOME" operation

    - SELECTION of ONE regex or LINE, below

	- A "CTRL + H" operation

    - ONE click on the "FIND NEXT" button

    - SEVERAL clicks on the "REPLACE" button  ( NOT the "REPLACE ALL" button ! )

against the string  "abgcd ef ghi j", PASTED in a NEW tab :


(?x-s).+?\K\x20           # KO  ( 3 SPACE chars NOT changed )
(?x-s).*?\K\x20           # OK  ( 3 SPACE chars CHANGED into @ )

(?x-is)(ab.*?\Kg|.*?\Kp)  # KO  ( TWO "g" NOT changed )
(?x-is)(ab.*?\Kg|.*?\Kh)  # KO  ( TWO "g" NOT changed, "h" CHANGED into @ only  )
(?x-is)(ab.*?\Kg|.*?\Kg)  # OK  ( TWO "g" CHANGED into @ )

(?x-is)(.*?\Kg|.*?\Kp)    # OK  ( TWO "g" CHANGED  into @ )
(?x-is)(.*?\Kg|.*?\Kh)    # OK  ( TWO "g" and "h" CHANGED into @  )
(?x-is)(.*?\Kg|.*?\Kg)    # OK  ( Two "g" CHANGED into @ )

(?x-is)a.*?\Kg            # KO  ( TWO "g" NOT changed )
(?x-is)\l.*?\Kg           # KO  ( TWO "g" NOT changed )

(?x-is).*?\Kg             # OK  ( TWO "g" CHANGED into @ )
(?x-is)(ab|)*?\Kg         # OK  ( TWO "g" CHANGED into @ )
(?x-is)(ab|\G)*?\Kg       # OK  ( TWO "g" CHANGED into @ )
</code></pre>
<hr />
<p dir="auto">Although the <strong><code>\K</code></strong> behavior is rather <strong>difficult</strong> to interpret, it seems, however, from the <strong>last</strong> example <strong><code>(?x-is)(ab|\G)*?\Kg</code></strong>, that the <strong>generic</strong> regex is <strong>compatible</strong> with <strong>several</strong> <em>“step by step”</em> replacements, using the <strong><code>Replace</code></strong> button <strong>only</strong>. So :</p>
<ul>
<li><strong>Paste</strong> the text, below, in a <strong>new</strong> tab :</li>
</ul>
<pre><code class="language-z">F

R

FR
B
S
R
FR

F
R

F

F


R


R

F

FR
E
S
R
FR

F
R

F

F


R


R

F

FR

FR
</code></pre>
<ul>
<li>
<p dir="auto">Move <strong>back</strong> to the <strong>very beginning</strong> ( <strong><code>Ctrl + Home</code></strong> )</p>
</li>
<li>
<p dir="auto">Open the <strong>Replace</strong> dialog ( <strong><code>Ctrl + H</code></strong> )</p>
</li>
</ul>
<pre><code class="language-z">SEARCH    (?x)  (?: (?s-i:B.*?S.*?R)  |  (?!\A)\G )  (?s-i:(?!E.*?S.*?R).)*?  \K  (?s-i:F\R*R)   #  With my FR version

REPLACE   @
</code></pre>
<ul>
<li>
<p dir="auto">Click <strong>once</strong> on the <strong>Find Next</strong> button ( it should select the first <strong>FR</strong>, after “<strong>BSR</strong>” )</p>
</li>
<li>
<p dir="auto">Then, click <strong>four</strong> times on the <strong><code>Replace</code></strong> button</p>
</li>
</ul>
<p dir="auto">=&gt; One at a time, the <strong>selected</strong> matched zone is <strong>replaced</strong> with the <strong><code>@</code></strong> sign ;-))</p>
<p dir="auto">and you should get that picture :</p>
<p dir="auto"><img src="/assets/uploads/files/1613268268096-f6b5af75-fa54-47d5-8b17-d294c1d8a33b-image.png" alt="f6b5af75-fa54-47d5-8b17-d294c1d8a33b-image.png" class=" img-fluid img-markdown" /></p>
<hr />
<p dir="auto">Now, <strong>Alan</strong>, it quite possible to <strong>avoid</strong> the <strong><code>\K</code></strong> assertion, with that syntax :</p>
<pre><code class="language-z">SEARCH    (?x)  (  (?: (?s-i:B.*?S.*?R)  |  (?!\A)\G )  (?s-i:(?!E.*?S.*?R).)*?  )  (?s-i:F\R*R)  #  With my FR version

REPLACE   \1@
</code></pre>
<p dir="auto">Remark that the <strong>replacement</strong> is <strong><code>\1@</code></strong> ( instead of <strong><code>@</code></strong> ). After running this <strong>S/R</strong>, in the <strong>same</strong> conditions as above, we get <strong>similar</strong> results ;-)</p>
<p dir="auto">However, note that, if we just search for the <strong>FR</strong> or try to <strong>mark</strong> the <strong>FR</strong> zones, that <strong>second</strong> syntax, <strong>without</strong> <strong><code>\K</code></strong>, is quite <strong>annoying</strong> and <strong>not</strong> really exact, as it <strong>does</strong> select <strong>FR</strong>, but it <strong>also</strong> selects :</p>
<ul>
<li>
<p dir="auto">The <strong>BSR</strong> part and anything till <strong>FR</strong></p>
</li>
<li>
<p dir="auto">Anything since <strong>last</strong> match till <strong>FR</strong></p>
</li>
</ul>
<hr />
<p dir="auto">Thirdly, <strong>Alan</strong>, regarding the <strong>precedence</strong> of the <strong>region</strong> to search for, over the effective <strong>FR</strong> match :</p>
<p dir="auto">As your <strong>FR</strong> regex <strong><code>(?s-i:F.*?R)</code></strong> contains a range of <strong>any</strong> char, <strong><code>EOL</code></strong> included, you need to <strong>restrict</strong> this area to an area <strong>not</strong> containing the <strong>ESR</strong>, too ! Thus, this fact changes <strong>your</strong> regex to :</p>
<pre><code class="language-z">SEARCH    (?x)  (?: (?s-i:B.*?S.*?R)  |  (?!\A)\G )  (?s-i:(?!E.*?S.*?R).)*?  \K  (?s-i:F((?!E.*?S.*?R).)*?R)   #  With your FR version
                                                                                  &lt;--- Find Regex---- FR ---&gt;
REPLACE   @
</code></pre>
<p dir="auto">Of course, <strong>your</strong> regex does <strong>not</strong> match exactly like my <strong>FR</strong> regex ! But the matches are <strong>correct</strong> and correctly <strong>limited</strong> in the <strong><code>BSR •••• ESR</code></strong> area. Moreover, the <strong>step by step</strong> replacement is still <strong>effective</strong> and give the picture below :</p>
<p dir="auto"><img src="/assets/uploads/files/1613268356775-84b156af-2571-49ac-a03f-405b9cc89009-image.png" alt="84b156af-2571-49ac-a03f-405b9cc89009-image.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">Best Regards,</p>
<p dir="auto">guy038</p>
<p dir="auto"><strong>P.S.</strong> :</p>
<p dir="auto">An <strong>other</strong> example :</p>
<p dir="auto">Let’s consider this text :</p>
<pre><code class="language-diff">/

/

The licenses/for most {software are/designed to/take away your} freedom/to share/and change it.

{By contrast, the/GNU General Public/License is } intended to/guarantee/your {freedom/to share and/change} free/software

This General/Public License/applies to {most of/the Free Software/Foundation's software}

{/}

/
/
</code></pre>
<ul>
<li>
<p dir="auto">Paste it in a <strong>new</strong> tab</p>
</li>
<li>
<p dir="auto">Move back to the <strong>beginning</strong> ( <strong><code>Ctrl + Home</code></strong> )</p>
</li>
</ul>
<p dir="auto">Now, let’s suppose that we want to change <strong>any</strong> <strong><code>/</code></strong> character into a <strong><code>@</code></strong> character, but <em>ONLY</em> in areas <strong>delimited</strong> by curly <strong>braces</strong> <strong><code>{ •••• }</code></strong>. Note that, in our <strong>sample</strong>, the <strong>second</strong> line contains <strong>two</strong> <strong><code>{ ••••• }</code></strong> zones. So :</p>
<ul>
<li>
<p dir="auto"><strong>FR</strong> = <strong><code>/</code></strong></p>
</li>
<li>
<p dir="auto"><strong>RR</strong> = <strong><code>@</code></strong></p>
</li>
<li>
<p dir="auto"><strong>BSR</strong> = <strong><code>\{</code></strong></p>
</li>
<li>
<p dir="auto"><strong>ESR</strong> = <strong><code>\}</code></strong></p>
</li>
</ul>
<p dir="auto">And gives this <strong>overall</strong> S/R :</p>
<pre><code class="language-z">SEARCH    (?x-si) (?:  \{  |  (?!\A)\G  )  (?: (?!\}). )*?  \K  /

REPLACE   @
</code></pre>
<p dir="auto">Remark that the part <strong><code>(?:(?!</code>ESR<code>).)*?</code></strong> , <strong>implicitly</strong>, defines an area which does <strong>not</strong> contain any <strong><code>}</code></strong> character till the <strong>next</strong> <strong><code>/</code></strong> char to search for. In other words, it tries to find a <strong><code>/</code></strong> <strong>before</strong> a possible <strong>further</strong> <strong><code>}</code></strong> character !</p>
<p dir="auto">=&gt; After <strong><code>1</code></strong> click on the <strong><code>Find Next</code></strong> button and <strong><code>9</code></strong> clicks on the <strong><code>Replace</code></strong> button, you’ll see that <strong>all</strong> occurrences of <strong><code>/</code></strong>, which are <strong>included</strong> in areas between <strong>curly braces</strong> <em>ONLY</em>, have been replaced, as <strong>expected</strong>, with the <strong><code>@</code></strong> symbol ;-))</p>
]]></description><link>https://community.notepad-plus-plus.org/post/62837</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/62837</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Sun, 14 Feb 2021 11:59:43 GMT</pubDate></item><item><title><![CDATA[Reply to Changing Data inside XML element on Sat, 13 Feb 2021 12:19:02 GMT]]></title><description><![CDATA[<p dir="auto">So the part that bothers me (slightly) is that as a user, I want to think of specifying the search region and the find regexes as independent entities.<br />
Maybe another way of saying it is that I’d like the search region to have precedence over the find.<br />
In my example 2 this doesn’t happen, and maybe there is no way to have it happen.</p>
<p dir="auto">With this, I run the risk of writing a bad replacement, that could be data dependent.<br />
Meaning that I could craft something that works well for a few cases at the top of a file where I’m testing it, but perhaps not all cases farther down in the file (or worse, multiple files).<br />
So I do my “few cases” analysis, deem it working, and then tell it to blast away at the rest of the file(s), and find out some time later that I’ve corrupted my data with errant replacements.</p>
<p dir="auto">Normally, in such a risky situation – if I know/suspect it to be so – I could tell myself “Don’t use this technique in a <em>Replace All</em> situation, just do a <em>Replace</em> (with implied <em>Find Next</em>) so that you can verify each replacement.”  But… this technique uses <code>\K</code> and individual-replace doesn’t work (certainly not your fault <a class="plugin-mentions-user plugin-mentions-a" href="/user/guy038" aria-label="Profile: guy038">@<bdi>guy038</bdi></a> – are the devs ever going to make it work?).</p>
<p dir="auto">Perhaps there are just always going to be such risks with certain techniques.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/62824</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/62824</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Sat, 13 Feb 2021 12:19:02 GMT</pubDate></item><item><title><![CDATA[Reply to Changing Data inside XML element on Sat, 13 Feb 2021 01:53:03 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> and <strong>All</strong>,</p>
<p dir="auto"><strong>Alan</strong>, you’re <strong>cheating</strong> a bit ! Let’s me explain :</p>
<hr />
<p dir="auto">I’ll use this <strong>sample</strong> text :</p>
<pre><code class="language-z">B
S
R
FR

F
R

F

F


R


R

F

FR
E
S
R
FR

F
R

F

F


R


R

F

FR

FR
</code></pre>
<p dir="auto">Your <strong>FR</strong> regex is <strong><code>(?s-i:F.*?R)</code></strong> which means : “Search for the <strong>shortest</strong> range, possibly <strong>empty</strong>, of any char, <strong><code>EOL</code></strong> included, between a <strong><code>F</code></strong> letter and a <strong><code>R</code></strong> letter, with that <strong>case</strong>”</p>
<p dir="auto">So, using <strong>only</strong> the regex <strong><code>(?s-i:F.*?R)</code></strong>, it matches, in the <strong><code>BSR •••••••• ESR</code></strong> area :</p>
<ul>
<li>
<p dir="auto">The string <strong>FR</strong>, line <strong><code>9</code></strong></p>
</li>
<li>
<p dir="auto">The string <strong>F<code>CRLF</code>R</strong>, lines <strong><code>11</code></strong> and <strong><code>12</code></strong></p>
</li>
<li>
<p dir="auto">The string <strong>F<code>CRLFCRLF</code>F<code>CRLFCRLFCRLF</code>R</strong>, between the lines <strong><code>14</code></strong> and <strong><code>19</code></strong></p>
</li>
<li>
<p dir="auto">The string <strong>F<code>CRLFCRLF</code>FR</strong>, between the lines <strong><code>24</code></strong> and <strong><code>26</code></strong></p>
</li>
</ul>
<hr />
<p dir="auto">Now, let’s consider this other <strong>FR</strong> regex <strong><code>(?s-i:F\R*R)</code></strong>. This regex searches for a <strong><code>F</code></strong>, with that <strong>case</strong>, followed with a range of <strong>consecutive</strong> <strong><code>EOL</code></strong> chars, possibly <strong>empty</strong>, till a <strong><code>R</code></strong> letter, with that <strong>case</strong>. I think this definition is <strong>close</strong> to what we expect to :</p>
<p dir="auto">Using this <strong>new</strong> version <strong><code>(?s-i:F\R*R)</code></strong>, it matches, in the <strong><code>BSR •••••••• ESR</code></strong> area :</p>
<ul>
<li>
<p dir="auto">The string <strong>FR</strong>, line <strong><code>9</code></strong></p>
</li>
<li>
<p dir="auto">The string <strong>F<code>CRLF</code>R</strong>, lines <strong><code>11</code></strong> and <strong><code>12</code></strong></p>
</li>
<li>
<p dir="auto">The string <strong>F<code>CRLFCRLFCRLF</code>R</strong>, between the lines <strong><code>16</code></strong> and <strong><code>19</code></strong></p>
</li>
<li>
<p dir="auto">The string <strong>FR</strong>, line <strong><code>26</code></strong></p>
</li>
</ul>
<hr />
<p dir="auto">So, if we use this <strong>overall</strong> regex ( only the <strong>FR</strong> part have been changed ) :</p>
<pre><code class="language-z">(?x)    (?-i:    (?s:B.*?S.*?R)    |  (?!\A)\G)    (?s:(?!E.*?S.*?R).)    *?\K    (?s-i:F\R*R)
</code></pre>
<p dir="auto">it <strong>correctly</strong> matches and marks :</p>
<ul>
<li>
<p dir="auto">The string <strong>FR</strong>, line <strong><code>9</code></strong>, <strong>right after</strong> the <strong><code>BSR</code></strong></p>
</li>
<li>
<p dir="auto">The string <strong>F<code>CRLF</code>R</strong>, lines <strong><code>11</code></strong> and <strong><code>12</code></strong></p>
</li>
<li>
<p dir="auto">The string <strong>F<code>CRLFCRLFCRLF</code>R</strong>, between the lines <strong><code>16</code></strong> and <strong><code>19</code></strong></p>
</li>
<li>
<p dir="auto">The string <strong>FR</strong>, line <strong><code>26</code></strong>, <strong>right before</strong> the <strong><code>ESR</code></strong></p>
</li>
<li>
<p dir="auto">And <strong>every other</strong> match of the simple regex <strong><code>(?s-i:F\R*R)</code></strong>, located <strong>after</strong> the <strong><code>ESR</code></strong>, are <strong>discarded</strong>, as expected ;-))</p>
</li>
</ul>
<p dir="auto">Refer the <strong>picture</strong>, below, where I’m using the <strong>regex</strong> in line <strong><code>3</code></strong> :</p>
<p dir="auto"><img src="/assets/uploads/files/1613171663060-12be4451-8fc2-4639-9073-8e7b3e970033-image.png" alt="12be4451-8fc2-4639-9073-8e7b3e970033-image.png" class=" img-fluid img-markdown" /></p>
<hr />
<p dir="auto">In summary, this <strong>generic</strong> regex seems quite <strong>robust</strong> !!</p>
<p dir="auto">Best Regards,</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/62818</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/62818</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Sat, 13 Feb 2021 01:53:03 GMT</pubDate></item><item><title><![CDATA[Reply to Changing Data inside XML element on Fri, 12 Feb 2021 20:58:31 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/62799">Changing Data inside XML element</a>:</p>
<blockquote>
<p dir="auto">(?-i:BSR|(?!\A)\G)(?s:(?!ESR).)*?\K(?-i:FR)</p>
</blockquote>
<p dir="auto">So I experimented a bit, and I found that it could be judged a bit “fragile”, from its higher-level intent.  Example:</p>
<p dir="auto">overall regex:</p>
<pre><code class="language-z">(?x)    (?-i:    (?s:B.*?S.*?R)    |(?!\A)\G)    (?s:(?!E.*?S.*?R).)    *?\K    (?s-i:F.*?R)
</code></pre>
<p dir="auto">data set 1:</p>
<pre><code class="language-z">B
S
R

FR

F
R

E
S
R

FR
</code></pre>
<p dir="auto">result 1 (intended):</p>
<p dir="auto"><img src="/assets/uploads/files/1613163335177-622a2226-481c-4854-b26b-a47c48743997-image.png" alt="622a2226-481c-4854-b26b-a47c48743997-image.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">data set 2:</p>
<pre><code class="language-z">B
S
R

FR

F


E
S
R

FR

</code></pre>
<p dir="auto">result 2 (unintended):</p>
<p dir="auto"><img src="/assets/uploads/files/1613163390757-4c2ac72f-10c3-43d3-b8f7-9e0c14f3fa2f-image.png" alt="4c2ac72f-10c3-43d3-b8f7-9e0c14f3fa2f-image.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">I certainly understand the reason for failure of result 2.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/62817</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/62817</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Fri, 12 Feb 2021 20:58:31 GMT</pubDate></item><item><title><![CDATA[Reply to Changing Data inside XML element on Fri, 12 Feb 2021 16:07:55 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/62799">Changing Data inside XML element</a>:</p>
<blockquote>
<p dir="auto">Alan, do you like it that way ?</p>
</blockquote>
<p dir="auto">I do have some suggestions; will post back after I have some more time to consider it.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/62816</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/62816</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Fri, 12 Feb 2021 16:07:55 GMT</pubDate></item><item><title><![CDATA[Reply to Changing Data inside XML element on Fri, 12 Feb 2021 14:35:56 GMT]]></title><description><![CDATA[<p dir="auto">Hello, <a class="plugin-mentions-user plugin-mentions-a" href="/user/matthew-allshorn" aria-label="Profile: matthew-allshorn">@<bdi>matthew-allshorn</bdi></a>, <a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: alan-kilborn">@<bdi>alan-kilborn</bdi></a> and All,</p>
<p dir="auto">Back to my <a class="plugin-mentions-user plugin-mentions-a" href="/user/matthew-allshorn" aria-label="Profile: matthew-allshorn">@<bdi>matthew-allshorn</bdi></a>’s <strong>search</strong> regex :</p>
<p dir="auto">SEARCH <strong><code>(?-i)(&lt;!\\[CDATA\\[|(?!\A)\G)[^]\r\n]*?\K/</code></strong></p>
<p dir="auto">I could have <strong>slightly</strong> modified it, as <strong><code>Regex_A</code></strong>, below which, in turn, could <strong>also</strong> be expressed, according to the <strong>generic</strong> syntax, as <strong><code>Regex_B</code></strong></p>
<pre><code class="language-z">Regex_A :   (?x-i)  (?:  &lt;!\\[CDATA\\[  |  (?!\A)\G)      [^&rsqb;&rsqb;      *?  \K  /

Regex_B :   (?x-i)  (?:  &lt;!\\[CDATA\\[  |  (?!\A)\G)  (?: (?!]).)   *?  \K  /

</code></pre>
<hr />
<p dir="auto">Now, <strong>Alan</strong>, I fully <strong>endorse</strong> your <strong>new</strong> abbreviations ! So :</p>
<ul>
<li>
<p dir="auto">Let <strong>FR</strong> (<strong><code>Find Regex</code></strong> ) be the regex which defines the <strong>char</strong>, <strong>string</strong> or <strong>expression</strong> to be searched</p>
</li>
<li>
<p dir="auto">Let <strong>RR</strong> (<strong><code>Replacement Regex</code></strong> ) be the regex which defines the <strong>char</strong>, <strong>string</strong> or <strong>expression</strong> which must replace the <strong>FR</strong> expression</p>
</li>
<li>
<p dir="auto">Let <strong>BSR</strong> ( <strong><code>Begin Search-region Regex</code></strong> ) be the regex which defines the <strong>beginning</strong> of the area where the search for <strong>FR</strong>, must <strong>start</strong></p>
</li>
<li>
<p dir="auto">Let <strong>ESR</strong> ( <strong><code>End Search-region Regex</code></strong>) be the regex which defines, <strong>implicitly</strong>, the area where the search for <strong>FR</strong>, must <strong>end</strong></p>
</li>
</ul>
<p dir="auto">Then, the <strong>generic</strong> regex can be expressed :</p>
<p dir="auto">SEARCH <strong><code>(?-i:</code>BSR<code>|(?!\A)\G)(?s:(?!</code>ESR<code>).)*?\K(?-i:</code>FR<code>)</code></strong></p>
<p dir="auto">REPLACE <strong>RR</strong></p>
<hr />
<p dir="auto"><strong>Important</strong> :</p>
<ul>
<li>
<p dir="auto">You <strong>must</strong> use, at least, the <strong><code>v7.9.1</code></strong> N++ release, so that the <strong><code>\A</code></strong> assertion is <strong>correctly</strong> handled</p>
</li>
<li>
<p dir="auto">You must, move the <strong>caret</strong> at the <strong>very beginning</strong> of current file ( <strong><code>Ctrl + Home</code></strong> ), if you plane a <strong><code>Replace All</code></strong> operation</p>
</li>
<li>
<p dir="auto">If <strong>all</strong> instances of <strong>FR</strong>, to <strong>match</strong>, are located in the <strong>same</strong> line as <strong>BSR</strong>, use <strong><code>(?-s)</code></strong> ( instead of <strong><code>(?s)</code></strong> ), in the appropriate <strong>non-capturing</strong> group</p>
</li>
<li>
<p dir="auto">If the <strong>BSR</strong> expression to match is <strong>independent</strong> from <strong>case</strong>, use <strong><code>(?i)</code></strong> ( instead of <strong><code>(?-i)</code></strong> ), in the appropriate <strong>non-capturing</strong> group</p>
</li>
<li>
<p dir="auto">If the <strong>FR</strong> expression to match is <strong>independent</strong> from <strong>case</strong>, use <strong><code>(?i)</code></strong> ( instead of <strong><code>(?-i)</code></strong> ), in the appropriate <strong>non-capturing</strong> group.</p>
</li>
<li>
<p dir="auto">Depending of the <strong>FR</strong> contents, when <strong>case</strong> is <strong>not</strong> concerned, you may, either :</p>
<ul>
<li>
<p dir="auto">Omit its <strong>non-capturing</strong> group and, if necessary, use the <strong><code>$0</code></strong> syntax, in the <strong>replacement</strong> regex <strong>RR</strong></p>
</li>
<li>
<p dir="auto">Define a <strong>group</strong> for some part of <strong>FR</strong>, which will be <strong>re</strong>-used in the <strong>replacement</strong> regex <strong>RR</strong></p>
</li>
</ul>
</li>
</ul>
<hr />
<p dir="auto"><strong>Alan</strong>, do you like it that way ?</p>
<p dir="auto">Best Regards,</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/62799</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/62799</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Fri, 12 Feb 2021 14:35:56 GMT</pubDate></item><item><title><![CDATA[Reply to Changing Data inside XML element on Fri, 12 Feb 2021 12:12:14 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></p>
<p dir="auto">Also, can we encapsulate the <code>(?s)</code> and <code>(?-s)</code> difference somehow, so you don’t have to publish TWO regexes that differ only in that leading element?</p>
<p dir="auto">Actually, shouldn’t it be up to the user to use <code>(?s)</code> or <code>(?-s)</code> as appropriate in their <strong>SR</strong>, <strong>ER</strong>, etc expressions?</p>
<p dir="auto">You have one use of <code>.</code> in the generic expression, perhaps it should have its own <code>(?s)</code> or <code>(?-s)</code> specifier that only relates to it?</p>
<p dir="auto">I suppose this gets even more complicated, but I’ll leave it to a “big regex thinker” like you. :-)</p>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/astrosofista" aria-label="Profile: astrosofista">@<bdi>astrosofista</bdi></a> said :</p>
<blockquote>
<p dir="auto">Not in my post, I used the \Q \E escape sequence to avoid that.</p>
</blockquote>
<p dir="auto">Right, I was of course meaning the others.<br />
But, it is probably bad to modify the regex you <em>want</em> to write, just so that it meets some criterion of the site it is posted on!</p>
]]></description><link>https://community.notepad-plus-plus.org/post/62790</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/62790</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Fri, 12 Feb 2021 12:12:14 GMT</pubDate></item><item><title><![CDATA[Reply to Changing Data inside XML element on Fri, 12 Feb 2021 12:08:52 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/62731">Changing Data inside XML element</a>:</p>
<blockquote>
<p dir="auto">I think the regexes shown above are victims of this site not being able to slow backslash followed by [ correctly!</p>
</blockquote>
<p dir="auto">Not in my post, I used the \Q \E escape sequence to avoid that.</p>
<p dir="auto">Cheers</p>
]]></description><link>https://community.notepad-plus-plus.org/post/62789</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/62789</guid><dc:creator><![CDATA[astrosofista]]></dc:creator><pubDate>Fri, 12 Feb 2021 12:08:52 GMT</pubDate></item><item><title><![CDATA[Reply to Changing Data inside XML element on Fri, 12 Feb 2021 00:23:02 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></p>
<p dir="auto">I think I misspoke before with my “end Exclusion Region” phraseology.<br />
I really meant (I think) to not use the word “exclusion”.<br />
Sure, that’s what the functionality in the overall regex is, but from a user instruction perspective, it confuses.  User is better to think in terms of start and end rather than start and exclusion.</p>
<p dir="auto">How about:</p>
<ul>
<li><strong>BSR</strong> (Begin Search-region Regex)</li>
<li><strong>ESR</strong> (End Search-region Regex)</li>
<li><strong>FR</strong> (Find Regex)</li>
<li><strong>RR</strong> (Replace Regex)</li>
</ul>
<p dir="auto">Of course, in the end, totally up to you.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/62776</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/62776</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Fri, 12 Feb 2021 00:23:02 GMT</pubDate></item><item><title><![CDATA[Reply to Changing Data inside XML element on Thu, 11 Feb 2021 22:36:07 GMT]]></title><description><![CDATA[<p dir="auto">Hi, <a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: alan-kilborn">@<bdi>alan-kilborn</bdi></a>,</p>
<p dir="auto">So, <strong>Alan</strong>, do you think these notations <strong>acceptable</strong> and my formulation <strong>clear</strong> enough ?</p>
<hr />
<ul>
<li>
<p dir="auto">Let <strong>SD</strong> (<strong><code>Search Definition</code></strong> ) be the regex which defines the <strong>char</strong>, <strong>string</strong> or <strong>expression</strong> to be searched</p>
</li>
<li>
<p dir="auto">Let <strong>RD</strong> (<strong><code>Replacement Definition</code></strong> ) be the regex which defines the <strong>char</strong>, <strong>string</strong> or <strong>expression</strong> which must replace the <strong>SD</strong> expression</p>
</li>
<li>
<p dir="auto">Let <strong>SR</strong> ( <strong><code>Start Region</code></strong> ) be the regex which defines the <strong>start</strong> of the area where the search for <strong>SD</strong>, must <strong>begin</strong></p>
</li>
<li>
<p dir="auto">Let <strong>ER</strong> ( <strong><code>Excluded Region</code></strong>) be the regex which defines, <strong>implicitly</strong>, the area where the search for <strong>SD</strong>, must <strong>stop</strong></p>
</li>
</ul>
<p dir="auto">Then, the <strong>generic</strong> regex can be expressed :</p>
<p dir="auto">SEARCH <strong><code>(?s)(?:</code>SR<code>|(?!\A)\G)(?:(?!</code>ER<code>).)*?\K(?:</code>SD<code>)</code></strong>    OR    <strong><code>(?-s)(?:</code>BR<code>|(?!\A)\G)(?:(?!</code>ER<code>).)*?\K(?:</code>SD<code>)</code></strong></p>
<p dir="auto">REPLACE <strong><code>RD</code></strong></p>
<hr />
<p dir="auto"><strong>Important</strong> :</p>
<ul>
<li>
<p dir="auto">You must use, at least, the <strong><code>v7.9.1</code></strong> N++ release, so that the <strong><code>\A</code></strong> assertion is <strong>correctly</strong> handled</p>
</li>
<li>
<p dir="auto">You must, move the <strong>caret</strong> at the <strong>very beginning</strong> of current file ( <strong><code>Ctrl + Home</code></strong> ), in case of a <strong><code>Replace All</code></strong> operation</p>
</li>
</ul>
<p dir="auto">BR</p>
<p dir="auto">guy038</p>
<p dir="auto"><strong>P.S.</strong> :</p>
<p dir="auto">Thereafter, if we agreed, I’ll try to get <strong>all</strong> of my posts, speaking of these *<em>notations</em> and will <strong>update</strong> them, accordingly !</p>
]]></description><link>https://community.notepad-plus-plus.org/post/62775</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/62775</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Thu, 11 Feb 2021 22:36:07 GMT</pubDate></item><item><title><![CDATA[Reply to Changing Data inside XML element on Thu, 11 Feb 2021 16:24:44 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/62748">Changing Data inside XML element</a>:</p>
<blockquote>
<p dir="auto">Now, Alan, your idea of ER for Excluded Region, with the same letters, is really clever :-)) And I think the BR notation could also refer to the Beginning Region. Do your agree to this idea ?<br />
We could also choose the SR notation for Start Region, but in this case, we need to change the old SR by SD ( Search Definition ) and the old RR by RD ( Replacement Definition !</p>
</blockquote>
<p dir="auto">I’m always agreeable to nice patterns and things that help make something easier to understand.  :-)</p>
]]></description><link>https://community.notepad-plus-plus.org/post/62751</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/62751</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Thu, 11 Feb 2021 16:24:44 GMT</pubDate></item><item><title><![CDATA[Reply to Changing Data inside XML element on Thu, 11 Feb 2021 16:19:58 GMT]]></title><description><![CDATA[<p dir="auto">Hello, <a class="plugin-mentions-user plugin-mentions-a" href="/user/matthew-allshorn" aria-label="Profile: matthew-allshorn">@<bdi>matthew-allshorn</bdi></a>, <a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: alan-kilborn">@<bdi>alan-kilborn</bdi></a> and All,</p>
<p dir="auto">Oh, my God ! Thanks, <strong>Alan</strong>, I’ve just updated my <strong>two</strong> previous posts, in order to get the <strong>right</strong> <strong><code>\\[</code></strong> syntax !</p>
<p dir="auto">Now, <strong>Alan</strong>, your idea of <strong>ER</strong> for <strong>Excluded Region</strong>, with the <strong>same</strong> letters, is really <strong>clever</strong> :-)) And I think the <strong>BR</strong> notation could also refer to the <strong>Beginning Region</strong>. Do your agree to this idea ?</p>
<p dir="auto">We could also choose the <strong>SR</strong> notation for <strong>Start Region</strong>, but in this case, we need to change the <em>old</em> <strong>SR</strong> by <strong>SD</strong> ( <strong>Search Definition</strong> ) and the <em>old</em> <strong>RR</strong> by <strong>RD</strong> ( <strong>Replacement Definition</strong> !</p>
<p dir="auto">Cheers,</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/62748</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/62748</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Thu, 11 Feb 2021 16:19:58 GMT</pubDate></item><item><title><![CDATA[Reply to Changing Data inside XML element on Thu, 11 Feb 2021 16:19:23 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/62742">Changing Data inside XML element</a>:</p>
<blockquote>
<p dir="auto">Because without proper escaping of the [, this isn’t going to be a valid regex</p>
</blockquote>
<p dir="auto">Due to site problems with posting backslash-then-<code>[</code>, maybe best to do <code>\Q[\E</code> instead!</p>
]]></description><link>https://community.notepad-plus-plus.org/post/62747</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/62747</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Thu, 11 Feb 2021 16:19:23 GMT</pubDate></item><item><title><![CDATA[Reply to Changing Data inside XML element on Thu, 11 Feb 2021 15:41:07 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/62738">Changing Data inside XML element</a>:</p>
<blockquote>
<p dir="auto">But I did use this method</p>
</blockquote>
<p dir="auto">I guess what I meant is, why not point back to the generic solution, during solving it specifically?<br />
That way people that want to learn have an opportunity, and perhaps could apply the general techniques themselves to their future problems.  Maybe I’m too hopeful.  :-)</p>
<p dir="auto">But for me, I’m always reading postings here trying to pick off new techniques.  If I had seen that this one was solved using a technique I already knew about, I’d save myself some time and stop reading. :-)</p>
<hr />
<blockquote>
<p dir="auto">May be, the notation ER, for Excluded Regex, has not the appropriate name…</p>
</blockquote>
<p dir="auto">I like thinking of it as “end Exclusion Region” :-)</p>
<hr />
<p dir="auto">Also, did you see my earlier statement?:</p>
<blockquote>
<p dir="auto">I think the regexes shown above are victims of this site not being able to slow backslash followed by [ correctly!</p>
</blockquote>
<p dir="auto">Because without proper escaping of the <code>[</code>, this isn’t going to be a valid regex:</p>
<p dir="auto"><img src="/assets/uploads/files/1613057944693-8427b9ea-efe8-45b1-a8ec-dc121df6f821-image.png" alt="8427b9ea-efe8-45b1-a8ec-dc121df6f821-image.png" class=" img-fluid img-markdown" /></p>
]]></description><link>https://community.notepad-plus-plus.org/post/62742</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/62742</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Thu, 11 Feb 2021 15:41:07 GMT</pubDate></item><item><title><![CDATA[Reply to Changing Data inside XML element on Thu, 11 Feb 2021 15:48:09 GMT]]></title><description><![CDATA[<p dir="auto">Hello, <a class="plugin-mentions-user plugin-mentions-a" href="/user/matthew-allshorn" aria-label="Profile: matthew-allshorn">@<bdi>matthew-allshorn</bdi></a>, <a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: alan-kilborn">@<bdi>alan-kilborn</bdi></a> and All,</p>
<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> :</p>
<p dir="auto">BUt I <strong>did</strong> use this method !  I just forgot the <strong><code>(?!\A)</code></strong> look-head in <strong>front</strong> of <strong><code>\G</code></strong> !</p>
<p dir="auto">Remember my <strong>notations</strong> :</p>
<ul>
<li>
<p dir="auto"><strong>BR</strong> = <strong><code>&lt;!\\[CDATA\\[</code></strong></p>
</li>
<li>
<p dir="auto"><strong>ER</strong> = <strong><code>[^]\r\n]*?</code></strong> which, implicitly, define the area where to search for a <strong>slash</strong> <strong><code>/</code></strong> character. indeed, the regex searches for the <strong>shortest</strong> range of characters, <strong>different</strong> from a <strong>closing square</strong> bracket <strong><code>]</code></strong> and <strong><code>EOL</code></strong> chars, till a <strong><code>/</code></strong> character. So the area, where to search for a <strong><code>/</code></strong>, <strong>begins</strong> right after the literal <strong>&lt;![CDATA[</strong> string and <strong>ends</strong> right before the <strong>&rsqb;&rsqb;&gt;</strong> string</p>
</li>
<li>
<p dir="auto"><strong>SR</strong> = <strong><code>/</code></strong></p>
</li>
<li>
<p dir="auto"><strong>RR</strong> = <strong><code>\x2d</code></strong></p>
</li>
</ul>
<hr />
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/matthew-allshorn" aria-label="Profile: matthew-allshorn">@<bdi>matthew-allshorn</bdi></a></p>
<p dir="auto">So, the <strong>safe</strong> method is :</p>
<ul>
<li>
<p dir="auto">Move the <strong>caret</strong> to the <strong>very beginning</strong> of <strong>current</strong> file ( <strong><code>Ctrl + Home</code></strong> )</p>
</li>
<li>
<p dir="auto">Open the <strong>Replace</strong> dialog ( <strong><code>Ctrl + H</code></strong> )</p>
<ul>
<li>
<p dir="auto">SEARCH <strong><code>(?-i)(&lt;!\\[CDATA\\[|(?!\A)\G)[^]\r\n]*?\K/</code></strong></p>
</li>
<li>
<p dir="auto">REPLACE <strong><code>\x2d</code></strong></p>
</li>
<li>
<p dir="auto">Select the <strong><code>Regular expression</code></strong> search <strong>mode</strong></p>
</li>
<li>
<p dir="auto">Click <strong>once</strong> on the <strong><code>Replace All</code></strong> mode</p>
</li>
</ul>
</li>
</ul>
<hr />
<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> :</p>
<p dir="auto">May be, the notation <strong>ER</strong>, for <strong>Excluded Regex</strong>, has not the <strong>appropriate</strong> name. Globally, this regex, built with a <strong>negative</strong> class char <strong><code>[^...]</code></strong> or with a <strong>negative</strong> look-ahead syntax <strong><code>((?!•••••••).)*?</code></strong>, defines , at the <strong>same</strong> time :</p>
<ul>
<li>
<p dir="auto">A zone, beginning with <strong>BR</strong>, where the search of <strong>SR</strong> is possible</p>
</li>
<li>
<p dir="auto">And, implicitly, any <strong>other</strong> areas, where the search of <strong>SR</strong> is strictly <strong>forbidden</strong></p>
</li>
</ul>
<p dir="auto">As soon as a char of the area is <strong>not</strong> valid, the regex must <strong>skip</strong> <strong><code>one</code></strong> or <strong><code>more</code></strong> characters to, possibly, <strong>match</strong> an other <strong>SR</strong> string, But this possibility is <strong>not</strong> allowed because of the <strong><code>\G</code></strong> assertion, which forces <strong>consecutive</strong> matches. So, this <strong>overall</strong> syntax guaranties that a <strong>new</strong> match attempt of <strong>SR</strong> should occur after a next <strong>BR</strong> string !</p>
<p dir="auto">Best Regards,</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/62738</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/62738</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Thu, 11 Feb 2021 15:48:09 GMT</pubDate></item><item><title><![CDATA[Reply to Changing Data inside XML element on Thu, 11 Feb 2021 12:41:57 GMT]]></title><description><![CDATA[<p dir="auto">I think the regexes shown above are victims of this site not being able to slow <em>backslash</em> followed by <code>[</code> correctly!</p>
<p dir="auto">Also, is there a reason the technique shown <a href="https://community.notepad-plus-plus.org/post/62131">HERE</a> is not employed to solve this one?</p>
]]></description><link>https://community.notepad-plus-plus.org/post/62731</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/62731</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Thu, 11 Feb 2021 12:41:57 GMT</pubDate></item><item><title><![CDATA[Reply to Changing Data inside XML element on Thu, 11 Feb 2021 15:46:08 GMT]]></title><description><![CDATA[<p dir="auto">Hello, <a class="plugin-mentions-user plugin-mentions-a" href="/user/matthew-allshorn" aria-label="Profile: matthew-allshorn">@<bdi>matthew-allshorn</bdi></a> and <strong>All</strong>,</p>
<p dir="auto">First, because of a <strong>wrong</strong> <strong><code>Markdown</code></strong> syntax, some part of your <strong>post</strong> was <strong>not</strong> displayed ! So, allow me to show the <strong>real</strong> contents of your <strong>post</strong> !</p>
<p dir="auto">Matthew said :</p>
<blockquote>
<p dir="auto">Have this as an example:</p>
</blockquote>
<blockquote>
<p dir="auto">&lt;ProductName&gt;&lt;![CDATA[Product Name Could be anything here L/XL&rsqb;&rsqb;&gt;&lt;/ProductName&gt;<br />
&lt;ProductName&gt;&lt;![CDATA[Product Name Could be anything here S/XXL&rsqb;&rsqb;&gt;&lt;/ProductName&gt;</p>
</blockquote>
<blockquote>
<p dir="auto">Have 7000 products, around 500 of them have “/” in the product names, which is coursing an issue in another process. So want to ignore anything before and after the “/” inside square brackets and only replace the “/” for the &lt;ProductName&gt;.</p>
</blockquote>
<blockquote>
<p dir="auto">How can I do a find and replace on the “/” to a “-” so that it will not course me issues in another process, please?</p>
</blockquote>
<hr />
<p dir="auto">Now, I’ve got a <strong>regex</strong> solution :</p>
<p dir="auto">SEARCH <strong><code>(&lt;!\\[CDATA\\[|\G)[^]\r\n]*?\K/</code></strong></p>
<p dir="auto">REPLACE <strong><code>\x2d</code></strong></p>
<hr />
<p dir="auto"><strong>Notes</strong> :</p>
<ul>
<li>
<p dir="auto">This regex may change several <strong>slash</strong> <strong><code>/</code></strong> characters, present in a <strong>single</strong> <strong><code>&lt;![CDATA[ .............. &rsqb;&rsqb;&gt;</code></strong> area</p>
</li>
<li>
<p dir="auto">This regex keeps the <strong>slash</strong> char(s) when found <strong>outside</strong> a <strong><code>&lt;![CDATA[ .............. &rsqb;&rsqb;&gt;</code></strong> area</p>
</li>
</ul>
<p dir="auto">Test it against that text :</p>
<pre><code class="language-diff">&lt;ProductName&gt;&lt;![CDATA[Product/Name Could be/anything/here S/XXL&rsqb;&rsqb;&gt;&lt;/ProductName&gt;&lt;p&gt;Test/Test / Test&lt;/p&gt;
</code></pre>
<p dir="auto">Best Regards,</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/62730</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/62730</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Thu, 11 Feb 2021 15:46:08 GMT</pubDate></item></channel></rss>