<?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[Replace character in capture group]]></title><description><![CDATA[<p dir="auto">I could have sworn I’ve asked this question before, and/or perhaps previously researched it online and located some code somewhere that I was able to adapt into something that worked for me at the time, but I’m not finding my adapted code, nor relevant posts here, nor any code I think I’m likely to have adapted from, now. I have a bunch of data that looks like this:</p>
<pre><code>"10001-word1-word2-word3"
"35058-word4-word5"
"41115-word6-word7-word8-word9-word10"
"47172-word11-word12"
"53229-word13-word14-word15"
"59286-word16-word17-word18-word19"
"65343-word20-word21-word22-word23-word24-word25"
"71400-word26-word27"
"77457-word28-word29-word30"
</code></pre>
<p dir="auto">I want to end up with this:</p>
<pre><code>word1 word2 word3
word4 word5
word6 word7 word8 word9 word10
word11 word12
word13 word14 word15
word16 word17 word18 word19
word20 word21 word22 word23 word24 word25
word26 word27
word28 word29 word30
</code></pre>
<p dir="auto">So basically, just all of the <code>word#</code>s, with hyphens replaced by spaces. I get as far as <code>"\d+-(.+?)"</code>, but that doesn’t replace the hyphens, of course. I see a few Stack Overflow topics <a href="https://stackoverflow.com/questions/40397220/regex-substitute-character-in-a-matching-substring" rel="nofollow ugc">here</a> and <a href="https://stackoverflow.com/questions/1007481/how-do-i-replace-whitespaces-with-underscore" rel="nofollow ugc">here</a> that appear to be tackling similar operations, but I fail to understand the proposed solutions sufficiently to make it possible for me to adapt them myself.</p>
<p dir="auto">Also, can anybody tell me what particular settings are the best to use for testing regex intended for NPP at <a href="https://regex101.com/" rel="nofollow ugc">Regex101</a>? I notice that <code>\l</code> works in NPP, and in NPP Python scripts, to match a lowercase letter, but not at Regex101 when I have it set to PCRE, in which case I have to change <code>\l</code> to <code>[[:lower:]]</code> or <code>[a-z]</code>. But if I switch Regex101 to Python, my code that otherwise worked no longer does, and I’m not sure what the issues are.</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/20219/replace-character-in-capture-group</link><generator>RSS for Node</generator><lastBuildDate>Tue, 19 May 2026 21:50:23 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/20219.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 26 Oct 2020 02:46:57 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Replace character in capture group on Mon, 02 Nov 2020 21:44:38 GMT]]></title><description><![CDATA[<p dir="auto">Hello, <a class="plugin-mentions-user plugin-mentions-a" href="/user/peterjones" aria-label="Profile: peterjones">@<bdi>peterjones</bdi></a>,</p>
<p dir="auto">Sorry, I’ve just seen your post where you asked people to <strong>verify</strong> the N++ official <strong>documentation</strong> ! I’ll try to have a look, myself, very <strong>soon</strong>. It would be better to do it <strong>before</strong> the <strong>next</strong> release of the website !</p>
<p dir="auto">But, as I said to <strong>Alan</strong>, at the moment, my <strong>TO DO</strong> list, concerning N++ or else, is getting much <strong>longer</strong> ;-))</p>
<p dir="auto">Cheers,</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/59362</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/59362</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Mon, 02 Nov 2020 21:44:38 GMT</pubDate></item><item><title><![CDATA[Reply to Replace character in capture group on Sat, 31 Oct 2020 17:53:00 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/peterjones" aria-label="Profile: PeterJones">@<bdi>PeterJones</bdi></a> said in <a href="/post/59294">Replace character in capture group</a>:</p>
<blockquote>
<p dir="auto">Looks good to me so far</p>
</blockquote>
<p dir="auto">Looked fine to me as well.<br />
Thanks for your fine attention to the manual.<br />
I just need to read it more when I have trouble with things. :-)</p>
]]></description><link>https://community.notepad-plus-plus.org/post/59298</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/59298</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Sat, 31 Oct 2020 17:53:00 GMT</pubDate></item><item><title><![CDATA[Reply to Replace character in capture group on Sat, 31 Oct 2020 16:53:45 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/m-andre-z-eckenrode" aria-label="Profile: M-Andre-Z-Eckenrode">@<bdi>M-Andre-Z-Eckenrode</bdi></a> said in <a href="/post/59267">Replace character in capture group</a>:</p>
<blockquote>
<p dir="auto">Looks good to me so far</p>
</blockquote>
<p dir="auto">Thanks.  Submitted <a href="https://community.notepad-plus-plus.org/topic/20219/replace-character-in-capture-group">PR #127</a>.  Hopefully, it will make it in before the next release of the <a href="http://npp-user-manual.org" rel="nofollow ugc">npp-user-manual.org</a> website.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/59294</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/59294</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Sat, 31 Oct 2020 16:53:45 GMT</pubDate></item><item><title><![CDATA[Reply to Replace character in capture group on Sat, 31 Oct 2020 01:04:52 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/m-andre-z-eckenrode" aria-label="Profile: M-Andre-Z-Eckenrode">@<bdi>M-Andre-Z-Eckenrode</bdi></a> said in <a href="/post/59267">Replace character in capture group</a>:</p>
<blockquote>
<p dir="auto">In selection checkbox was sometimes ghosted</p>
</blockquote>
<p dir="auto"><em>In selection</em> checkbox enabled condition:  A single selection of one or more characters, that is NOT a column block selection.</p>
<p dir="auto">Note that the checkbox’s appearance status can only be relied upon when you actually switch input focus to the find (family) window – upon activation the code runs a check to make sure you have the proper type of selection, and updates the checkbox and its state at that time.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/59270</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/59270</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Sat, 31 Oct 2020 01:04:52 GMT</pubDate></item><item><title><![CDATA[Reply to Replace character in capture group on Sat, 31 Oct 2020 00:59:36 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/m-andre-z-eckenrode" aria-label="Profile: M-Andre-Z-Eckenrode">@<bdi>M-Andre-Z-Eckenrode</bdi></a> said in <a href="/post/59268">Replace character in capture group</a>:</p>
<blockquote>
<p dir="auto">I think I’ve already made it fairly clear, in my previous posts to this thread, that that’s what I’m finding to be the case.</p>
</blockquote>
<p dir="auto">Perhaps, but I get the feeling you might be holding on to regex101 a bit much. :-)</p>
<p dir="auto">Plus, I’m kind of a late joiner to this thread; there’s a lot of content.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/59269</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/59269</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Sat, 31 Oct 2020 00:59:36 GMT</pubDate></item><item><title><![CDATA[Reply to Replace character in capture group on Sat, 31 Oct 2020 00:56:38 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/59265">Replace character in capture group</a>:</p>
<blockquote>
<p dir="auto">the caliber of stuff you have been discussing in this thread is going to be different in N++ and regex101.</p>
</blockquote>
<p dir="auto">I think I’ve already made it fairly clear, in my previous posts to this thread, that that’s what I’m finding to be the case.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/59268</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/59268</guid><dc:creator><![CDATA[M Andre Z Eckenrode]]></dc:creator><pubDate>Sat, 31 Oct 2020 00:56:38 GMT</pubDate></item><item><title><![CDATA[Reply to Replace character in capture group on Sat, 31 Oct 2020 00:50:11 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/peterjones" aria-label="Profile: PeterJones">@<bdi>PeterJones</bdi></a> said in <a href="/post/59262">Replace character in capture group</a>:</p>
<blockquote>
<p dir="auto">Could you both look at the proposed <a href="https://github.com/pryrt/npp-usermanual/blob/searching-backref/content/docs/searching.md#capture-groups-and-backreferences" rel="nofollow ugc">capture groups and backreferences phrasing</a> and <a href="https://github.com/pryrt/npp-usermanual/blob/searching-backref/content/docs/searching.md#substitution-escape-sequences" rel="nofollow ugc">substitution phrasing</a> , and make sure that the updated sections makes the distinction more clear?</p>
</blockquote>
<p dir="auto">Looks good to me so far, though coming from a fairly green regex user like me, I’d take that with a grain of salt.  :-)</p>
<p dir="auto">On a tangent here, I’ve noticed, on occasion when doing find/replace operations, that the <code>In selection</code> checkbox was sometimes ghosted (not available to check or uncheck), which I keep meaning to compile a list of circumstances for presentation and inquiry in these forums sometime. I notice that in both official and proposed versions of the doc, there seems to be no mention of any limitations on when the <code>In selection</code> checkbox is available. There seem to be some known limitations (at least one of which is mentioned <a href="https://community.notepad-plus-plus.org/post/48926">here</a>). Maybe they should be added to the docs?</p>
]]></description><link>https://community.notepad-plus-plus.org/post/59267</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/59267</guid><dc:creator><![CDATA[M Andre Z Eckenrode]]></dc:creator><pubDate>Sat, 31 Oct 2020 00:50:11 GMT</pubDate></item><item><title><![CDATA[Reply to Replace character in capture group on Sat, 31 Oct 2020 00:18:22 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/m-andre-z-eckenrode" aria-label="Profile: M-Andre-Z-Eckenrode">@<bdi>M-Andre-Z-Eckenrode</bdi></a></p>
<p dir="auto">DO NOT rely on regex101 for the more esoteric aspects of regex.  Doing so, and then intending to use the results in Notepad++ will cause frustration.  Sure, okay, for simple cases, but the caliber of stuff you have been discussing in this thread is going to be different in N++ and regex101.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/59265</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/59265</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Sat, 31 Oct 2020 00:18:22 GMT</pubDate></item><item><title><![CDATA[Reply to Replace character in capture group on Fri, 30 Oct 2020 23:58:51 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/59258">Replace character in capture group</a>:</p>
<blockquote>
<p dir="auto">repl: <code>abc_$+{Name}_xyz</code><br />
your examples show you were trying to use <code>\g</code> which I believe only works in the find expression.</p>
</blockquote>
<p dir="auto">Aha! Looks that’s true in NPP — though <code>\g&lt;Name&gt;</code> actually <strong>DOES</strong> work in PCRE replacement expressions at <a href="https://regex101.com/r/Bu6gmq/2" rel="nofollow ugc">Regex101</a>.</p>
<p dir="auto">Thanks for the education.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/59264</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/59264</guid><dc:creator><![CDATA[M Andre Z Eckenrode]]></dc:creator><pubDate>Fri, 30 Oct 2020 23:58:51 GMT</pubDate></item><item><title><![CDATA[Reply to Replace character in capture group on Fri, 30 Oct 2020 23:51:44 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/m-andre-z-eckenrode" aria-label="Profile: M-Andre-Z-Eckenrode">@<bdi>M-Andre-Z-Eckenrode</bdi></a> ,</p>
<blockquote>
<p dir="auto">I can’t get any of the syntaxes listed … Replacement Expression</p>
</blockquote>
<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/59258">Replace character in capture group</a>:</p>
<blockquote>
<p dir="auto">I believe only works in the find expression</p>
</blockquote>
<p dir="auto">You are correct.</p>
<p dir="auto">And you weren’t the <a href="https://github.com/notepad-plus-plus/npp-usermanual/issues/125" rel="nofollow ugc">first person this week</a> to not notice that the <code>\g</code> and <code>\k</code> syntaxes are in the search section, and not in the replacement section (which tried to be explicit that any syntax not mentioned in the replacement section was not valid in the replacement field, but has apparently failed).</p>
<p dir="auto">Could you both look at the proposed <a href="https://github.com/pryrt/npp-usermanual/blob/searching-backref/content/docs/searching.md#capture-groups-and-backreferences" rel="nofollow ugc">capture groups and backreferences phrasing</a> and <a href="https://github.com/pryrt/npp-usermanual/blob/searching-backref/content/docs/searching.md#substitution-escape-sequences" rel="nofollow ugc">substitution phrasing</a> , and make sure that the updated sections makes the distinction more clear?</p>
<p dir="auto">-–<br />
<em>Note to future readers: those “phrasing” links are to a temporary branch, and in the future, they will not work. <a href="https://npp-user-manual.org/docs/searching/" rel="nofollow ugc">https://npp-user-manual.org/docs/searching/</a> is the official location of the search documentation, and <a href="https://github.com/notepad-plus-plus/npp-usermanual/blob/master/content/docs/searching.md" rel="nofollow ugc">https://github.com/notepad-plus-plus/npp-usermanual/blob/master/content/docs/searching.md</a> is the master github source for the document.</em></p>
]]></description><link>https://community.notepad-plus-plus.org/post/59262</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/59262</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Fri, 30 Oct 2020 23:51:44 GMT</pubDate></item><item><title><![CDATA[Reply to Replace character in capture group on Fri, 30 Oct 2020 23:14:45 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/m-andre-z-eckenrode" aria-label="Profile: M-Andre-Z-Eckenrode">@<bdi>M-Andre-Z-Eckenrode</bdi></a> said in <a href="/post/59257">Replace character in capture group</a>:</p>
<blockquote>
<p dir="auto">I can’t get any of the syntaxes</p>
</blockquote>
<p dir="auto">If I use this as the replace-with expression for your search-for expression and data:</p>
<p dir="auto">find: <code>ABC(?&lt;Name&gt;.+?)XYZ</code><br />
repl: <code>abc_$+{Name}_xyz</code><br />
data to search: <code>ABCDEFGHIJKLMNOPQRSTUVWXYZ</code></p>
<p dir="auto">I obtain:</p>
<p dir="auto"><code>abc_DEFGHIJKLMNOPQRSTUVW_xyz</code></p>
<p dir="auto">I tell you that because you were asking about “replacement expression”.</p>
<p dir="auto">However, your examples show you were trying to use <code>\g</code> which I believe only works in the find expression.  Example:</p>
<p dir="auto">find: <code>(?&lt;Name&gt;t...)ING\g&lt;Name&gt;</code></p>
<p dir="auto">which would match:</p>
<p dir="auto">data to search: <code>testINGtest</code> or <code>testINGtrip</code></p>
<p dir="auto">A similar but distinctly different example:</p>
<p dir="auto">find: <code>(?&lt;Name&gt;t...)ING(?&amp;Name)</code></p>
<p dir="auto">which would match:</p>
<p dir="auto">data to search: <code>testINGtest</code> or <code>tripINGtrip</code> but not <code>testINGtrip</code></p>
]]></description><link>https://community.notepad-plus-plus.org/post/59258</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/59258</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Fri, 30 Oct 2020 23:14:45 GMT</pubDate></item><item><title><![CDATA[Reply to Replace character in capture group on Fri, 30 Oct 2020 22:35:29 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/59242">Replace character in capture group</a>:</p>
<blockquote>
<p dir="auto">maybe what you’re looking for is called a “subroutine call” and not a “backreference”?<br />
See more in this excellent posting:</p>
</blockquote>
<p dir="auto">I don’t <em><strong>THINK</strong></em> I’m confusing the two — I’m actually trying to utilize both — though considering my track record with this particular excercise, it wouldn’t come as a complete shock to learn otherwise. But thanks in any case for the link to that truly informative post. I think I could, however, benefit from many working examples of usage in various situations.</p>
<p dir="auto">As far as named capture groups go, I can’t get any of the syntaxes listed in the post and the online NPP doc to actually work in NPP. For example, given text <code>ABCDEFGHIJKLMNOPQRSTUVWXYZ</code>, and search expression <code>ABC(?&lt;Name&gt;.+?)XYZ</code>, I get the following:</p>
<pre><code>Replacement Expression		Result
------------------------------------------
\g&lt;Name&gt;             	=	g&lt;Name&gt;
\g'Name'             	=	g'Name'
\g{Name}             	=	g{Name}
</code></pre>
<p dir="auto">Equivalent results using <code>\k</code>. Do any of these actually work for anybody else?</p>
]]></description><link>https://community.notepad-plus-plus.org/post/59257</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/59257</guid><dc:creator><![CDATA[M Andre Z Eckenrode]]></dc:creator><pubDate>Fri, 30 Oct 2020 22:35:29 GMT</pubDate></item><item><title><![CDATA[Reply to Replace character in capture group on Fri, 30 Oct 2020 17:03:36 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/m-andre-z-eckenrode" aria-label="Profile: M-Andre-Z-Eckenrode">@<bdi>M-Andre-Z-Eckenrode</bdi></a> said in <a href="/post/59240">Replace character in capture group</a>:</p>
<blockquote>
<p dir="auto">…but not:</p>
</blockquote>
<p dir="auto">Not 100% sure because I haven’t followed the preceding in a super-detailed fashion, but maybe what you’re looking for is called a “subroutine call” and not a “backreference”?</p>
<p dir="auto">The syntactical difference is:</p>
<ul>
<li><code>\1</code> 🡢 backreference</li>
<li><code>(?1)</code> -&gt; subroutine</li>
</ul>
<p dir="auto">See more in this excellent posting: <a href="https://community.notepad-plus-plus.org/post/56447">https://community.notepad-plus-plus.org/post/56447</a></p>
<p dir="auto">If I’m totally off-base, well, at least the “excellent posting” reference contains some otherwise good stuff. :-)</p>
]]></description><link>https://community.notepad-plus-plus.org/post/59242</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/59242</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Fri, 30 Oct 2020 17:03:36 GMT</pubDate></item><item><title><![CDATA[Reply to Replace character in capture group on Fri, 30 Oct 2020 16:43:44 GMT]]></title><description><![CDATA[<p dir="auto">Ok, so it looks like I can use:</p>
<p dir="auto"><code>(?:&lt;p class="credits"&gt;(&lt;span class="contributors"&gt;)|(&lt;\/span&gt;)&lt;span class="contributors"&gt;|&lt;\/span&gt;&lt;\/p&gt;)</code></p>
<p dir="auto">…but not:</p>
<p dir="auto"><code>(?:&lt;p class="credits"&gt;(&lt;span class="contributors"&gt;)|(&lt;\/span&gt;)\1|\2&lt;\/p&gt;)</code></p>
<p dir="auto">…so I think I’ve learned that numbered backreferences used in alternation sequences are unique for each sequence. That wasn’t clear to me from the online docs for <a href="https://npp-user-manual.org/docs/searching/#capture-groups-and-backreferences" rel="nofollow ugc">NPP</a> and <a href="https://www.boost.org/doc/libs/1_70_0/libs/regex/doc/html/boost_regex/syntax/perl_syntax.html" rel="nofollow ugc">Boost Perl Regular Expression Syntax 1.70.0</a>, but I guess makes sense now that I think about it.  :-)</p>
]]></description><link>https://community.notepad-plus-plus.org/post/59240</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/59240</guid><dc:creator><![CDATA[M Andre Z Eckenrode]]></dc:creator><pubDate>Fri, 30 Oct 2020 16:43:44 GMT</pubDate></item><item><title><![CDATA[Reply to Replace character in capture group on Fri, 30 Oct 2020 04:28:23 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/terry-r" aria-label="Profile: Terry-R">@<bdi>Terry-R</bdi></a> said in <a href="/post/59186">Replace character in capture group</a>:</p>
<blockquote>
<p dir="auto">Unfortunately some of your guesses aren’t quite right.</p>
</blockquote>
<p dir="auto">Figured that would turn out to be the case.  :-)</p>
<blockquote>
<p dir="auto">Might I suggest you plug this into the website:<br />
<a href="https://regex101.com/" rel="nofollow ugc">https://regex101.com/</a></p>
</blockquote>
<p dir="auto">I have fairly often used that site — in fact, I brought up the subject of my mixed successes with it in my first post for this topic thread — and concur that it’s often helpful and informative, but sometimes frustrating, at least for an amateur whose ambitions often exceed his understanding and abilities, like me. For the regex operations we’re discussing in this thread, Regex101 seems not very helpful at all with the substitution expressions. If I plug <a class="plugin-mentions-user plugin-mentions-a" href="/user/guy038" aria-label="Profile: guy038">@<bdi>guy038</bdi></a>’s original suggested expressions (in response to my first post) into Regex101:</p>
<p dir="auto"><strong>FIND</strong>: <code>^"\d+-|\G([\u\l]+\d+)((-)|")</code></p>
<p dir="auto"><strong>REPLACE</strong>: <code>?1\1?3\x20</code></p>
<p dir="auto">…I have to change <code>[\u\l]</code> to something else like <code>[[:alpha:]]</code> because PCRE via Regex101 apparently doesn’t recognize the former. And used there, the substitution expression results in:</p>
<pre><code>?1?3 ?1word1?3 ?1word2?3 ?1word3?3 
?1?3 ?1word4?3 ?1word5?3 
?1?3 ?1word6?3 ?1word7?3 ?1word8?3 ?1word9?3 ?1word10?3 
</code></pre>
<p dir="auto">I don’t know if there are other ways of expressing it that are Regex101/PCRE-friendly.</p>
<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/59208">Replace character in capture group</a>:</p>
<blockquote>
<p dir="auto">First I would like to <strong>apologize</strong> !</p>
</blockquote>
<p dir="auto">No apologies necessary! You’re way better at this than I am, and I appreciate your help (and everyone else’s)!</p>
<blockquote>
<p dir="auto">So the <strong><code>\G</code></strong> assertion, which searches from the location of the <strong>end</strong> of the <strong>previous</strong> match, is <strong>not</strong> needed at all !</p>
</blockquote>
<p dir="auto">Noted, and thanks for all the detailed explanations.</p>
<blockquote>
<p dir="auto">Now, we just have to run this <strong>trivial</strong> regex S/R, to change any <strong>dash</strong>, between the <strong>forename</strong> and the <strong>name</strong>, with a <strong>space</strong> character</p>
</blockquote>
<p dir="auto">I’m afraid that would be a less-than-ideal solution, but I think it’s my own fault for neglecting to provide adequate examples and explanation. In the fictitious example HTML code I provided, all the contributors had only first and last names, but of course in real life some people get referred to using three or more names — John David Hatch, Mary Anne Perry, etc. I was specifically trying to adapt your regex search/replace methods in <code>^"\d+-|\G([\u\l]+\d+)((-)|")</code> and <code>?1\1?3\x20</code> to use with my made-up HTML, and would want it to also work if any persons had three or more names. Also, I assume that if I ever actually needed to operate on HTML similar to my example code, there might also be other hyphens, outside of the blocks of code I’d be targeting for manipulation, that need to be left alone. Again, I failed to mention these possibilities in my posts, even though I had them in my mind, and I apologize.</p>
<blockquote>
<p dir="auto"><a href="https://www.regular-expressions.info/" rel="nofollow ugc">https://www.regular-expressions.info/</a></p>
</blockquote>
<p dir="auto">I have consulted that site on occasion as well.</p>
<p dir="auto">Trying a modified tactic now… My data to be manipulated:</p>
<pre><code>&lt;p class="credits"&gt;&lt;span class="contributors"&gt;Writer – &lt;a href="/contribs/001-John-Doe"&gt;J. Doe&lt;/a&gt;, &lt;a href="/contribs/003-Jane-Johnson"&gt;J. Johnson&lt;/a&gt;&lt;/span&gt;&lt;span class="contributors"&gt;Producer – &lt;a href="/contribs/002-Timothy-Smith"&gt;T. Smith&lt;/a&gt;&lt;/span&gt;&lt;span class="contributors"&gt;Director – &lt;a href="/contribs/003-Jane-Johnson"&gt;J. Johnson&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
</code></pre>
<p dir="auto">The difference between the HTML immediately above and that which I’d posted <a href="https://community.notepad-plus-plus.org/post/59185">here</a> is that now there are two names/hyperlinks after “Writer”, so I’m looking to make this step of regex break the credit role/name(s) into one line per set, whether or not there are multiple names/hyperlinks given for a credit role.</p>
<p dir="auto"><strong>FIND</strong>: <code>(?:&lt;p class="credits"&gt;(&lt;span class="contributors"&gt;)|(&lt;\/span&gt;)\1|\2&lt;\/p&gt;)</code></p>
<p dir="auto"><strong>REPLACE</strong>: <code>(?1\t\1)(?2\2\r\n\t\1)(?3\2)</code></p>
<p dir="auto">Desired result:</p>
<pre><code>	&lt;span class="contributors"&gt;Writer – &lt;a href="/contribs/001-John-Doe"&gt;J. Doe&lt;/a&gt;, &lt;a href="/contribs/003-Jane-Johnson"&gt;J. Johnson&lt;/a&gt;&lt;/span&gt;
	&lt;span class="contributors"&gt;Producer – &lt;a href="/contribs/002-Timothy-Smith"&gt;T. Smith&lt;/a&gt;&lt;/span&gt;
	&lt;span class="contributors"&gt;Director – &lt;a href="/contribs/003-Jane-Johnson"&gt;J. Johnson&lt;/a&gt;&lt;/span&gt;
</code></pre>
<p dir="auto">Actual result:</p>
<pre><code>	&lt;span class="contributors"&gt;Writer – &lt;a href="/contribs/001-John-Doe"&gt;J. Doe&lt;/a&gt;, &lt;a href="/contribs/003-Jane-Johnson"&gt;J. Johnson&lt;/a&gt;&lt;/span&gt;&lt;span class="contributors"&gt;Producer – &lt;a href="/contribs/002-Timothy-Smith"&gt;T. Smith&lt;/a&gt;&lt;/span&gt;&lt;span class="contributors"&gt;Director – &lt;a href="/contribs/003-Jane-Johnson"&gt;J. Johnson&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
</code></pre>
<p dir="auto">Looks like in both NPP and <a href="https://regex101.com/r/RF8Wta/1" rel="nofollow ugc">Regex101</a>, only the first alternation expression <code>&lt;p class="credits"&gt;(&lt;span class="contributors"&gt;)</code> matches anything. No idea why the other two won’t. I can match any of them separately, but not as other than a first alternation expression.</p>
<p dir="auto">If I had gotten this to work, my next, separate regex step would be to try to get to this:</p>
<pre><code>	John Doe, Jane Johnson — writer
	Timothy Smith — producer
	Jane Johnson — director
</code></pre>
]]></description><link>https://community.notepad-plus-plus.org/post/59215</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/59215</guid><dc:creator><![CDATA[M Andre Z Eckenrode]]></dc:creator><pubDate>Fri, 30 Oct 2020 04:28:23 GMT</pubDate></item><item><title><![CDATA[Reply to Replace character in capture group on Thu, 29 Oct 2020 20:09:41 GMT]]></title><description><![CDATA[<p dir="auto">Hi, <a class="plugin-mentions-user plugin-mentions-a" href="/user/m-andre-z-eckenrode" aria-label="Profile: m-andre-z-eckenrode">@<bdi>m-andre-z-eckenrode</bdi></a>, <a class="plugin-mentions-user plugin-mentions-a" href="/user/ekopalypse" aria-label="Profile: ekopalypse">@<bdi>ekopalypse</bdi></a>, <a class="plugin-mentions-user plugin-mentions-a" href="/user/terry-r" aria-label="Profile: terry-r">@<bdi>terry-r</bdi></a> and <strong>All</strong>,</p>
<p dir="auto">First I would like to <strong>apologize</strong> ! Indeed, in the example of your <strong>previous</strong> post, the <strong>different</strong> parts to search are <strong>consecutive</strong>. So the <strong><code>\G</code></strong> assertion ,which searches from the location of the <strong>end</strong> of the <strong>previous</strong> match, is <strong>not</strong> needed  at all !</p>
<p dir="auto">So my <strong>previous</strong> S/R is :</p>
<p dir="auto">SEARCH <strong><code>^"\d+-|([\u\l]+\d+)((-)|")</code></strong></p>
<p dir="auto">REPLACE <strong><code>?1\1?3\x20</code></strong></p>
<hr />
<p dir="auto">Now, in your <strong>recent</strong> example, the general idea is to match a <strong>complete</strong> range <strong><code>&lt;span......&lt;/span&gt;</code></strong> and to <strong>only</strong> extract <strong>pertinent</strong> parts that you want to keep in <strong>replacement</strong> and <strong>re-order</strong> them as you like !</p>
<p dir="auto">I will use the <strong>free-spacing</strong> mode ( <strong><code>(?x)</code></strong> ) which generally helps to better understand <strong>complicated</strong> regexes . In this mode, the regex can be <strong>split</strong> over <strong>several</strong> lines.</p>
<ul>
<li>
<p dir="auto"><strong>Any</strong> line can be <strong>commented</strong> after a <strong><code>#</code></strong> symbol. To search for a <strong>literal</strong> <strong><code>#</code></strong> just <strong>escape</strong> it <strong><code>\#</code></strong></p>
</li>
<li>
<p dir="auto">Any <strong>space</strong> symbol is <strong>irrelevant</strong> so use the syntaxes <strong><code>\x20</code></strong>, <strong><code>[ ]</code></strong> or <strong>escape</strong> it with the <strong><code>\</code></strong> symbol to search for a <strong>space</strong> char</p>
</li>
</ul>
<hr />
<p dir="auto">Before, Just an example to grasp the <strong>nuance</strong> between <strong>greedy</strong> and <strong>lazy</strong> quantifiers :</p>
<p dir="auto">Let’s suppose the regex **<code>ABC.+XYZ</code>*, with the <strong>lazy</strong> quantifer <strong><code>+</code></strong>,  against the string <strong>67890ABC123451234512345XYZ678906789067890XYZ12345</strong> =&gt; It catches the string<br />
<strong>ABC123451234512345XYZ678906789067890XYZ</strong>, so the <strong>greatest</strong> non-null range of chars between the strings <strong><code>ABC</code></strong> and <strong><code>XYZ</code></strong></p>
<p dir="auto">Now, if we add a <strong>question mark</strong> right after the sign <strong><code>+</code></strong>, we get the regex <strong><code>ABC.+?XYZ</code></strong>, with the <strong>lazy</strong> quantifier <strong><code>+?</code></strong>. Thus, it would <strong>only</strong> match the string <strong>ABC123451234512345XYZ</strong> which is the <strong>smallest</strong> non-null range of chars between the strings <strong><code>ABC</code></strong> and <strong><code>XYZ</code></strong></p>
<hr />
<p dir="auto">OK. So, the <strong>search</strong> regex can be written according to this form :</p>
<pre><code class="language-z">(?x)                              #  FREE-SPACING mode
(?-s)                             #  A DOT matches a SINGLE STANDARD char ( Not EOL chars )
  &lt;span\x20class="contributors"&gt;  #    LITERAL string  span class="contributors"&gt;
(                                 #  START of CAPTURING group 1 ( the PROFESSION )
  .+?                             #    SMALLEST NON-NULL range of STANDARDS characters... till the string \x20–\x20&lt;a
)                                 #  END of CAPTURING group 1
\x20–\x20&lt;a                       #  LITERAL string SPACE + EN-Dash \x{2013} + SPACE + "&lt;a" s
.+?                               #  SMALLEST NON-NULL range of STANDARDS characters... till a DASH punctuation sign
-                                 #  The LITTERAL DASH punctuation sign
(                                 #  START of CAPTURING group 2 ( the COMPLETE name )
  .+?                             #    SMALLEST NON-NULL range of STANDARDS characters... till the string "&gt;
)                                 #    END of CAPTURING group 2
"&gt;                                #  LITERAL string  "&gt;
.+?                               #  SMALLEST NON-NULL range of STANDARDS characters... till the string &lt;/span&gt;
&lt;/span&gt;                           #  LITERAL string &lt;/span&gt;
</code></pre>
<p dir="auto">And written in a <strong>single</strong> line, it becomes :</p>
<p dir="auto">SEARCH <strong><code>(?x-s)&lt;span\x20class="contributors"&gt;(.+?)\x20–\x20&lt;a.+?-(.+?)"&gt;.+?&lt;/span&gt;</code></strong></p>
<p dir="auto">Unfortunately, this <strong>free-spacing</strong> mode is <strong>not</strong> available for the <strong>replacement</strong> regex syntax. So we <strong>still</strong> need to write :</p>
<p dir="auto">REPLACEMENT <strong><code>\2 — \1\r\n</code></strong>    which can be decomposed as :</p>
<pre><code class="language-z">\2        = The COMPLETE name ( Group 2 )
 —        = A SPACE char + a EM DASH char \x{2014} + a SPACE
\1        = The PROFESSION  ( Group 1 )
\r\n      = A LINE-BREAK
</code></pre>
<p dir="auto">So, from your <strong>initial</strong> text :</p>
<pre><code class="language-xml">&lt;span class="contributors"&gt;Writer – &lt;a href="/contribs/001-John-Doe"&gt;J. Doe&lt;/a&gt;&lt;/span&gt;&lt;span class="contributors"&gt;Producer – &lt;a href="/contribs/002-Timothy-Smith"&gt;T. Smith&lt;/a&gt;&lt;/span&gt;&lt;span class="contributors"&gt;Director – &lt;a href="/contribs/003-Jane-Johnson"&gt;J. Johnson&lt;/a&gt;&lt;/span&gt;
</code></pre>
<p dir="auto">After running the <strong>regex</strong> S/R, we get :</p>
<pre><code class="language-xml">John-Doe — Writer
Timothy-Smith — Producer
Jane-Johnson — Director
</code></pre>
<p dir="auto">Now, we just have to run this <strong>trivial</strong> regex S/R, to change any <strong>dash</strong>, between the <strong>forename</strong> and the <strong>name</strong>, with a <strong>space</strong> character</p>
<p dir="auto">SEARCH <strong><code>-</code></strong></p>
<p dir="auto">REPLACE <strong><code>\x20</code></strong></p>
<p dir="auto">Here is your <strong>expected</strong> text :</p>
<pre><code class="language-xml">John Doe — Writer
Timothy Smith — Producer
Jane Johnson — Director
</code></pre>
<hr />
<p dir="auto">Now, in order to be <strong>fluent</strong> in regex matters, I’d like to <strong>advise</strong> you <strong>not</strong> to fixate on these <strong>ready-made</strong> regex examples from this forum and, instead, to start the <strong><code>"b-a-ba"</code></strong> with this <strong>excellent</strong> tutorial on <strong>regular</strong> expressions ( the <strong>reference</strong> !)</p>
<p dir="auto"><a href="https://www.regular-expressions.info/" rel="nofollow ugc">https://www.regular-expressions.info/</a></p>
<p dir="auto">You’ll probably need <strong>half</strong> a month to be <strong>acquainted</strong> with and, let’s say, <strong>four</strong> months to build up <strong>correct</strong> regexes, for a <strong>specific</strong>need, in a <strong>few</strong> minutes ! But it’s really worth it ;-))</p>
<p dir="auto">Best Regards,</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/59208</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/59208</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Thu, 29 Oct 2020 20:09:41 GMT</pubDate></item><item><title><![CDATA[Reply to Replace character in capture group on Wed, 28 Oct 2020 21:02:09 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/m-andre-z-eckenrode" aria-label="Profile: M-Andre-Z-Eckenrode">@<bdi>M-Andre-Z-Eckenrode</bdi></a> said in <a href="/post/59185">Replace character in capture group</a>:</p>
<blockquote>
<p dir="auto">but here’s all I know or have guessed so far:</p>
</blockquote>
<p dir="auto">Unfortunately some of your guesses aren’t quite right. Might I suggest you plug this into the website:<br />
<a href="https://regex101.com/" rel="nofollow ugc">https://regex101.com/</a><br />
as that provides great explanations of all the sub-expressions.</p>
<p dir="auto">As a starter you will see that the <code>|</code> is in fact the alternation symbol and yes the <code>\d+</code> DOES form part of a alternate sub-expression.</p>
<p dir="auto">Terry</p>
]]></description><link>https://community.notepad-plus-plus.org/post/59186</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/59186</guid><dc:creator><![CDATA[Terry R]]></dc:creator><pubDate>Wed, 28 Oct 2020 21:02:09 GMT</pubDate></item><item><title><![CDATA[Reply to Replace character in capture group on Wed, 28 Oct 2020 20:39:52 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">As I wrote in my previous reply to your <a href="https://community.notepad-plus-plus.org/post/59090">post</a>, your suggested regex code works perfectly for my current needs. I’m not sure I’ll ever have another need for the same sort of operation (replacing all instances of a particular character within a capture group), but I’d like very much to be able to have a full understanding of how your regex code works, so that I could effectively apply in some other situation, should the need ever arise. Towards that end, I’ve been generating different sets of sample data of my own invention, and attempting to adapt your code to operate on them. For example, I came up with this fictitious set of html code:</p>
<pre><code>&lt;span class="contributors"&gt;Writer – &lt;a href="/contribs/001-John-Doe"&gt;J. Doe&lt;/a&gt;&lt;/span&gt;&lt;span class="contributors"&gt;Producer – &lt;a href="/contribs/002-Timothy-Smith"&gt;T. Smith&lt;/a&gt;&lt;/span&gt;&lt;span class="contributors"&gt;Director – &lt;a href="/contribs/003-Jane-Johnson"&gt;J. Johnson&lt;/a&gt;&lt;/span&gt;
</code></pre>
<p dir="auto">My attempt to adapt your regex to work on the code above:</p>
<p dir="auto"><strong>FIND</strong> : <code>– &lt;a href="\/contribs\/\d+-|\G(\w+)((-)|")&gt;.+?&lt;\/a&gt;&lt;\/span&gt;</code><br />
<strong>REPLACE</strong>: <code>— ?1\1?3\x20\r\n</code></p>
<p dir="auto">My desired result:</p>
<pre><code>&lt;span class="contributors"&gt;Writer — John Doe
&lt;span class="contributors"&gt;Producer — Timothy Smith
&lt;span class="contributors"&gt;Director — Jane Johnson
</code></pre>
<p dir="auto">Actual result:</p>
<pre><code>&lt;span class="contributors"&gt;Writer — John-Doe"&gt;J. Doe&lt;/a&gt;&lt;/span&gt;&lt;span class="contributors"&gt;Producer — Timothy-Smith"&gt;T. Smith&lt;/a&gt;&lt;/span&gt;&lt;span class="contributors"&gt;Director — Jane-Johnson"&gt;J. Johnson&lt;/a&gt;&lt;/span&gt;
</code></pre>
<p dir="auto">If I’d gotten that to work so far, I next would have tried my hand at also removing the <code>&lt;span&gt;</code> tags at the beginning and swapping the two sets of remaining information before and after the m-dash <code>—</code>:</p>
<pre><code>John Doe — Writer
Timothy Smith — Producer
Jane Johnson — Director
</code></pre>
<p dir="auto">Any chance you could break your regex code down and explain the various parts to me? Much of it I’m sure I already know, from other (simpler) operations I’ve done, but here’s all I know or have guessed so far:</p>
<p dir="auto"><code>^</code> = Beginning of line (or of text, if <code>(?s)</code> setting were used)</p>
<p dir="auto"><code>"\d+-</code> = literal double-quote, followed by 1 or more digits, followed by literal hyphen</p>
<p dir="auto"><code>|</code> = I know this as a divider between alternation expressions, but not sure why it’s used here in this location, since <code>"\d+-</code> isn’t part of an alternation sequence</p>
<p dir="auto"><code>\G</code> = matches only at end of last match found, or at start of text being matched if no previous match found</p>
<p dir="auto"><code>([\u\l]+\d+)</code> = Capture group 1: Any combination of one or more upper or lower case characters, followed by one or digits</p>
<p dir="auto"><code>((-)|")</code> = Capture group 2: Alternation sequence of a hyphen (capture group 3), <strong>OR</strong> a double quote mark, one of which follows each word matched by <code>([\u\l]+\d+)</code></p>
<p dir="auto">The <strong>REPLACE</strong> expression is trickier, for me:</p>
<p dir="auto"><code>?1</code> = Not strictly familiar with this use, that I recall, though looks somewhat like <code>(?***N***)</code>, defined in the Boost v1.70.0 regex docs as a recursive execution of sub-expression <em><strong>N</strong></em>, but without the parenthesis.</p>
<p dir="auto"><code>\1</code> = Capture group 1 (AKA sub-expression 1, I think)</p>
<p dir="auto"><code>?3</code> = Execution of sub-expression 3?</p>
<p dir="auto"><code>\x20</code> = space</p>
]]></description><link>https://community.notepad-plus-plus.org/post/59185</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/59185</guid><dc:creator><![CDATA[M Andre Z Eckenrode]]></dc:creator><pubDate>Wed, 28 Oct 2020 20:39:52 GMT</pubDate></item><item><title><![CDATA[Reply to Replace character in capture group on Tue, 27 Oct 2020 03:54:09 GMT]]></title><description><![CDATA[<p dir="auto">Hello,<a class="plugin-mentions-user plugin-mentions-a" href="/user/m-andre-z-eckenrode" aria-label="Profile: M-Andre-Z-Eckenrode">@<bdi>M-Andre-Z-Eckenrode</bdi></a><br />
Please follow these steps, To Replace a character in the capture group</p>
<p dir="auto"><strong>Step 1:-</strong> Open Notepad++ with the file for replace<br />
<strong>Step 2:-</strong> Replace menu Ctrl+H<br />
<strong>Step 3:-</strong> or Find menu - Ctrl+F<br />
<strong>Step 4:-</strong> Check the Regular expression (at the bottom)<br />
<strong>Step 5:-</strong> Write in Find what<br />
<strong>Step 6:-</strong> \d+<br />
<strong>Step 7:-</strong> Replace with:X<br />
<strong>Step 8:-</strong> ReplaceAll</p>
<p dir="auto">I hope this information will be useful to you.<br />
Thank you.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/59118</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/59118</guid><dc:creator><![CDATA[Makwana Prahlad]]></dc:creator><pubDate>Tue, 27 Oct 2020 03:54:09 GMT</pubDate></item><item><title><![CDATA[Reply to Replace character in capture group on Tue, 27 Oct 2020 01:02:52 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/ekopalypse" aria-label="Profile: Ekopalypse">@<bdi>Ekopalypse</bdi></a> &amp; <a class="plugin-mentions-user plugin-mentions-a" href="/user/guy038" aria-label="Profile: guy038">@<bdi>guy038</bdi></a>, thank you both for the information about the various regex testers.</p>
<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/59090">Replace character in capture group</a>:</p>
<blockquote>
<p dir="auto">I suppose that the following <strong>regex</strong> S/R</p>
<p dir="auto">SEARCH <strong><code>^"\d+-|\G([\u\l]+\d+)((-)|")</code></strong></p>
<p dir="auto">REPLACE <strong><code>?1\1?3\x20</code></strong></p>
<p dir="auto">just gives the <strong>expected</strong> output :</p>
</blockquote>
<p dir="auto">Works well in NPP here. Thanks much again. (Note: When I tried using this search pattern in the Regex Trainer: Expression panel, it reported an error parsing it. The Regex Tester that came as a sample script with Python Script looks like I need to study it a bit before I can effectively use it.)</p>
<blockquote>
<p dir="auto">A simple solution, to avoid any problem, is to use the <strong><code>Wrap around</code></strong> option and insert an <strong>empty</strong> line to the <strong>very beginning</strong> of file</p>
</blockquote>
<p dir="auto">Thanks for the warnings. It shouldn’t be a problem with my usage, though.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/59117</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/59117</guid><dc:creator><![CDATA[M Andre Z Eckenrode]]></dc:creator><pubDate>Tue, 27 Oct 2020 01:02:52 GMT</pubDate></item><item><title><![CDATA[Reply to Replace character in capture group on Tue, 27 Oct 2020 04:27:21 GMT]]></title><description><![CDATA[<p dir="auto">Hello, <a class="plugin-mentions-user plugin-mentions-a" href="/user/m-andre-z-eckenrode" aria-label="Profile: m-andre-z-eckenrode">@<bdi>m-andre-z-eckenrode</bdi></a>, <a class="plugin-mentions-user plugin-mentions-a" href="/user/ekopalypse" aria-label="Profile: ekopalypse">@<bdi>ekopalypse</bdi></a>, <a class="plugin-mentions-user plugin-mentions-a" href="/user/terry-r" aria-label="Profile: terry-r">@<bdi>terry-r</bdi></a> and <strong>All</strong>,</p>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/m-andre-z-eckenrode" aria-label="Profile: m-andre-z-eckenrode">@<bdi>m-andre-z-eckenrode</bdi></a>, I’m afraid that the <strong>sole</strong> decent <strong>regex tester</strong> is <strong><code>RegexBuddy</code></strong> from the <strong><code>Just Great Software</code></strong> company, created by <strong><code>Jan Goyvaerts</code></strong></p>
<p dir="auto">Of course, this product is not <strong>free</strong>, but if you need <strong>support</strong> on regexes, that you <strong>cannot</strong> get, after Notepad++ regex <strong>tests</strong>, it’s <strong>The Reference</strong> product in the “<em>regex world</em>” !! Note that the <strong>price</strong> of about <strong><code>35$</code> for such a powerful</strong> software is <strong>not</strong> very expensive. considering its <strong>good</strong> return on investment ratio ;-))</p>
<p dir="auto">For instance, just have a look to <strong>all</strong> the regex flavors that <strong><code>RegexBuddy</code></strong> can handle : <strong><code>264</code></strong>  flavors !! Refer to the list, below :</p>
<p dir="auto"><a href="https://www.regexbuddy.com/compare.html#flavors" rel="nofollow ugc">https://www.regexbuddy.com/compare.html#flavors</a></p>
<p dir="auto">And I would say, that the <strong>closest</strong> flavor to use with N++ should be <strong><code>boost::wregex 1.66–1.73</code></strong> as N++ is compiled with <strong><code>Boost v1.70</code></strong></p>
<hr />
<p dir="auto">Now, let’s go <strong>back</strong> to your problem :</p>
<p dir="auto">From your <strong>initial</strong> text :</p>
<pre><code class="language-diff">"10001-word1-word2-word3"
"35058-word4-word5"
"41115-word6-word7-word8-word9-word10"
"47172-word11-word12"
"53229-word13-word14-word15"
"59286-word16-word17-word18-word19"
"65343-word20-word21-word22-word23-word24-word25"
"71400-word26-word27"
"77457-word28-word29-word30"
</code></pre>
<p dir="auto">I suppose that the following <strong>regex</strong> S/R</p>
<p dir="auto">SEARCH <strong><code>^"\d+-|\G([\u\l]+\d+)((-)|")</code></strong></p>
<p dir="auto">REPLACE <strong><code>?1\1?3\x20</code></strong></p>
<p dir="auto">just gives the <strong>expected</strong> output :</p>
<pre><code class="language-diff">word1 word2 word3
word4 word5
word6 word7 word8 word9 word10
word11 word12
word13 word14 word15
word16 word17 word18 word19
word20 word21 word22 word23 word24 word25
word26 word27
word28 word29 word30
</code></pre>
<p dir="auto">However, be <strong>aware</strong> of two points :</p>
<ul>
<li>
<p dir="auto">If, right before running this S/R, the <strong>cursor</strong> is on a line, <strong>outside</strong> your block, which begins with a <strong>double</strong> quote followed with some <strong>digits</strong> and a <strong>dash</strong> as, for instance <strong><code>"987772-</code></strong>, a <strong>match</strong> would occur and be <strong>deleted</strong> !</p>
</li>
<li>
<p dir="auto">In the <strong>same</strong> way, due to the <strong><code>\G</code></strong> feature, if the cursor is , <strong>outside</strong> your block, right before the <strong>string</strong> <strong><code>word123-</code></strong> or <strong><code>word37"</code></strong> a match would also occur and would changed as <strong><code>Word123</code></strong> followed with a <strong>space</strong> char or as <strong><code>word37</code></strong></p>
</li>
</ul>
<p dir="auto">A simple solution, to avoid any problem, is to use the <strong><code>Wrap around</code></strong> option and insert an <strong>empty</strong> line to the <strong>very beginning</strong> of file</p>
<p dir="auto">Best Regards</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/59090</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/59090</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Tue, 27 Oct 2020 04:27:21 GMT</pubDate></item><item><title><![CDATA[Reply to Replace character in capture group on Mon, 26 Oct 2020 13:10:00 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/m-andre-z-eckenrode" aria-label="Profile: M-Andre-Z-Eckenrode">@<bdi>M-Andre-Z-Eckenrode</bdi></a></p>
<p dir="auto">The RegexTrainer seems to use dotnet regex enigne which, if I correctly remember,<br />
is based on the java regex engine.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/59087</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/59087</guid><dc:creator><![CDATA[Ekopalypse]]></dc:creator><pubDate>Mon, 26 Oct 2020 13:10:00 GMT</pubDate></item><item><title><![CDATA[Reply to Replace character in capture group on Mon, 26 Oct 2020 13:07:41 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/m-andre-z-eckenrode" aria-label="Profile: M-Andre-Z-Eckenrode">@<bdi>M-Andre-Z-Eckenrode</bdi></a> said in <a href="/post/59085">Replace character in capture group</a>:</p>
<blockquote>
<p dir="auto">Anything to be said for it versus the separate Regex Trainer plugin? I’ve used the latter a bit, but found it to be not as informative as Regex101.</p>
</blockquote>
<p dir="auto">I wasn’t aware of this one - the script doesn’t do any explanation like the regex101 site. It just colors the text based on your regex instantly.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/59086</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/59086</guid><dc:creator><![CDATA[Ekopalypse]]></dc:creator><pubDate>Mon, 26 Oct 2020 13:07:41 GMT</pubDate></item><item><title><![CDATA[Reply to Replace character in capture group on Mon, 26 Oct 2020 13:05:12 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/terry-r" aria-label="Profile: Terry-R">@<bdi>Terry-R</bdi></a> said in <a href="/post/59077">Replace character in capture group</a>:</p>
<blockquote>
<p dir="auto">we need ALL the types of data that you need to change</p>
</blockquote>
<p dir="auto">The example in my first post is the only type of data I need to change, at least at this time, and can be reliably matched by <code>"\d+-(.+?)"</code>, as far as I have seen so far. Other examples of hyphens used throughout my data file are probably too numerous to try to give them all here, but none of the others I’ve made note of are sandwiched between <code>"\d+-</code> and <code>"</code> I’m just hoping to be able to replace what’s matched with just my target words <strong>AND</strong> replace the hyphens with spaces at the same time.</p>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/ekopalypse" aria-label="Profile: Ekopalypse">@<bdi>Ekopalypse</bdi></a> said in <a href="/post/59079">Replace character in capture group</a>:</p>
<blockquote>
<p dir="auto">the PythonScript plugin has a regex tester example</p>
</blockquote>
<p dir="auto">Anything to be said for it versus the separate Regex Trainer plugin? I’ve used the latter a bit, but found it to be not as informative as Regex101.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/59085</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/59085</guid><dc:creator><![CDATA[M Andre Z Eckenrode]]></dc:creator><pubDate>Mon, 26 Oct 2020 13:05:12 GMT</pubDate></item></channel></rss>