<?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[RegEX - Find and rename special words (letter)]]></title><description><![CDATA[<p dir="auto">How I can replace all special words in the TXT file with letter (-) to (_)?</p>
<p dir="auto">All replace words beginn with $:</p>
<p dir="auto">Example:</p>
<ol>
<li>$this-is_my_test</li>
<li>testfile\tmp$test-old_name -Value abc\no-wow</li>
</ol>
<p dir="auto">My wish:<br />
$this_is_my_test<br />
testfile\tmp$test_old_name -Value abc\no_wow</p>
<p dir="auto">I have tested : $(.*)\ <br />
this is not right because (.) and the space between two words are not found.<br />
I have no idea with regex. Sorry.</p>
<p dir="auto">Can anybody help me?<br />
Thanks!</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/20671/regex-find-and-rename-special-words-letter</link><generator>RSS for Node</generator><lastBuildDate>Wed, 17 Jun 2026 16:55:40 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/20671.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 02 Feb 2021 14:21:01 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to RegEX - Find and rename special words (letter) on Tue, 02 Feb 2021 16:34:08 GMT]]></title><description><![CDATA[<p dir="auto">Hi <a class="plugin-mentions-user plugin-mentions-a" href="/user/venus642" aria-label="Profile: venus642">@<bdi>venus642</bdi></a>,</p>
<p dir="auto">Sorry, I updated my <strong>search</strong> regex to :</p>
<p dir="auto">SEARCH <strong><code>(?-s)(\$|(?!\A)\G).*?\K(?&lt;=\w)-</code></strong></p>
<p dir="auto">Refer to my <strong>previous</strong> post that I <strong>updated</strong> too, for the <strong>hypotheses</strong> to respect and some <strong>other</strong> pieces of information !</p>
<p dir="auto">BR</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/62428</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/62428</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Tue, 02 Feb 2021 16:34:08 GMT</pubDate></item><item><title><![CDATA[Reply to RegEX - Find and rename special words (letter) on Tue, 02 Feb 2021 16:15:56 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/venus642" aria-label="Profile: Venus642">@<bdi>Venus642</bdi></a> said in <a href="/post/62426">RegEX - Find and rename special words (letter)</a>:</p>
<blockquote>
<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/62424">RegEX - Find and rename special words (letter)</a>:</p>
<blockquote>
<p dir="auto">(?-s)($|(?!\A)\G).*?\K(?&lt;=\w)-</p>
</blockquote>
<p dir="auto">Yes! This work fine for me…<br />
Big thanks!</p>
<p dir="auto">Thank’s PeterJones and guy038!</p>
</blockquote>
]]></description><link>https://community.notepad-plus-plus.org/post/62427</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/62427</guid><dc:creator><![CDATA[Venus642]]></dc:creator><pubDate>Tue, 02 Feb 2021 16:15:56 GMT</pubDate></item><item><title><![CDATA[Reply to RegEX - Find and rename special words (letter) on Tue, 02 Feb 2021 16:00:00 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/62424">RegEX - Find and rename special words (letter)</a>:</p>
<blockquote>
<p dir="auto">(?-s)($|\G).*?\K(?&lt;=\w)-</p>
</blockquote>
<p dir="auto">Yes! This work fine for me…<br />
Big thanks!</p>
<p dir="auto">Thank’s PeterJones and guy038!</p>
]]></description><link>https://community.notepad-plus-plus.org/post/62426</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/62426</guid><dc:creator><![CDATA[Venus642]]></dc:creator><pubDate>Tue, 02 Feb 2021 16:00:00 GMT</pubDate></item><item><title><![CDATA[Reply to RegEX - Find and rename special words (letter) on Tue, 02 Feb 2021 15:55:23 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> , <a class="plugin-mentions-user plugin-mentions-a" href="/user/venus642" aria-label="Profile: Venus642">@<bdi>Venus642</bdi></a> ,</p>
<p dir="auto">My second regex will work, <em>if</em> you use Replace All.  Sorry I forgot to mention it.  (\K often requires Replace All)</p>
<p dir="auto">My first regex works whether you use multiple replace clicks, or replace all, because it’s using simple groups rather than match-reset or lookbehind.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/62425</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/62425</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Tue, 02 Feb 2021 15:55:23 GMT</pubDate></item><item><title><![CDATA[Reply to RegEX - Find and rename special words (letter) on Tue, 02 Feb 2021 20:27:57 GMT]]></title><description><![CDATA[<p dir="auto">Hello, <a class="plugin-mentions-user plugin-mentions-a" href="/user/venus642" aria-label="Profile: venus642">@<bdi>venus642</bdi></a>, <a class="plugin-mentions-user plugin-mentions-a" href="/user/peterjones" aria-label="Profile: peterjones">@<bdi>peterjones</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 <strong>All</strong>,</p>
<p dir="auto"><strong>Two</strong> hypotheses must be <strong>verified</strong>, before executing the <strong>regex</strong> S/R, below :</p>
<ul>
<li>
<p dir="auto">You must use the N++ version <strong><code>7.9.1</code></strong> or a <strong>later</strong> version, which <strong>correctly</strong> handles the behavior of the <strong><code>\A</code></strong> assertion</p>
</li>
<li>
<p dir="auto">You <strong>systematically</strong> must move the caret to the <strong>very beginning</strong> of current file ( <strong><code>Ctrl + Home</code></strong> ). This hypothesis is <strong>implicit</strong> for a <strong><code>Find All in Current Document</code></strong>, a <strong><code>Find in All Opened Documents</code></strong> or a <strong><code>Find All</code></strong> operation !</p>
</li>
</ul>
<hr />
<p dir="auto">So, let’s start from this text :</p>
<pre><code class="language-z">    $this-is_my_test

    test-file\tmp$test-old_name -Value $abc\no-wow
</code></pre>
<p dir="auto">If we use the following regex S/R :</p>
<p dir="auto">SEARCH <strong><code>(?-s)(\$|(?!\A)\G).*?\K(?&lt;=\w)-</code></strong></p>
<p dir="auto">REPLACE <strong><code>_</code></strong></p>
<p dir="auto">we get the <strong>expected</strong> text :</p>
<pre><code class="language-z">    $this_is_my_test

    test-file\tmp$test_old_name -Value $abc\no_wow
</code></pre>
<p dir="auto">Note that I <strong>slightly</strong> changed the <strong>beginning</strong> of your second line  ( <strong><code>test-file</code></strong> instead of <strong><code>testfile</code></strong> )</p>
<p dir="auto">And, as you can see in the <strong>output</strong> text, that <strong>dash</strong> character <strong><code>-</code></strong> have <strong>not</strong> been changed because it is located <strong>before</strong> the <strong><code>$</code></strong> symbol !</p>
<p dir="auto">On the other hand, the <strong>dash</strong> char, in the string <strong><code>-Value</code></strong> has <strong>no</strong>t been modified, either, as <strong>not following</strong> a letter !</p>
<p dir="auto">Best regards,</p>
<p dir="auto">guy038</p>
<p dir="auto"><strong>P.S.</strong> :</p>
<p dir="auto"><strong>Alan</strong>, doesn’t this type of regex remind you of something ? Yes, my <strong>last generic</strong> regex ! Refer to the <strong>end</strong> part of this post  :</p>
<p dir="auto"><a href="https://community.notepad-plus-plus.org/post/62131">https://community.notepad-plus-plus.org/post/62131</a></p>
<p dir="auto">In our <strong>present</strong> example :</p>
<ul>
<li>
<p dir="auto"><strong>BR</strong> = <strong><code>\$</code></strong></p>
</li>
<li>
<p dir="auto"><strong>ER</strong> is <strong>implicit</strong>. Indeed, the syntax <strong><code>(?-s).*?</code></strong> is <strong>identical</strong> to the regex <strong><code>[^\r\n\f]*?</code></strong>, which represents the <em>virtual</em> <strong>Excluded Regex</strong> !</p>
</li>
<li>
<p dir="auto"><strong>SR</strong> = <strong><code>-</code></strong></p>
</li>
<li>
<p dir="auto"><strong>RR</strong> = <strong><code>_</code></strong></p>
</li>
</ul>
<hr />
<p dir="auto">An <strong>other</strong> example in this post    <a href="https://community.notepad-plus-plus.org/post/62396">https://community.notepad-plus-plus.org/post/62396</a>     ( where I forgot the <strong><code>(?!\A)</code></strong> <strong>look-around</strong> ! )</p>
<ul>
<li>
<p dir="auto"><strong>BR</strong> = <strong><code>\$</code></strong></p>
</li>
<li>
<p dir="auto"><strong>ER</strong> is <strong>implicit</strong> : again, the <strong>Excluded Regex (ER)</strong> is the regex <strong><code>[^\r\n]</code></strong></p>
</li>
<li>
<p dir="auto"><strong>SR</strong> = <strong><code>(0)|(1)|(2)</code></strong></p>
</li>
<li>
<p dir="auto"><strong>RR</strong> = <strong><code>(?1G)(?2H)(?3I)</code></strong></p>
</li>
</ul>
]]></description><link>https://community.notepad-plus-plus.org/post/62424</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/62424</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Tue, 02 Feb 2021 20:27:57 GMT</pubDate></item><item><title><![CDATA[Reply to RegEX - Find and rename special words (letter) on Tue, 02 Feb 2021 15:21:26 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><br />
Thanks for your info.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/62423</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/62423</guid><dc:creator><![CDATA[Venus642]]></dc:creator><pubDate>Tue, 02 Feb 2021 15:21:26 GMT</pubDate></item><item><title><![CDATA[Reply to RegEX - Find and rename special words (letter) on Tue, 02 Feb 2021 15:00:01 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/venus642" aria-label="Profile: Venus642">@<bdi>Venus642</bdi></a> ,</p>
<p dir="auto">The first problem with your regex is the <code>$</code> character: in Notepad++'s regular expressions, that means “end of line”.  If you want to match the literal <code>$</code> character in a regex, you need to escape it: <code>\$</code>.</p>
<p dir="auto">When solving a problem like yours, I try to state the problem in my native language in a way that encapsulates <em>all</em> of my requirements: “to be matched (and later replaced), the <code>-</code> must have the literal $ with one or more letter characters before it and must have one or more letter characters after it, but I only want the <code>-</code> to be replaced”.</p>
<p dir="auto">There are lots of ways to implement that sentence.</p>
<p dir="auto">First, I know there is going to be a <code>-</code> in my regex, because that’s the only character I want to really replace.  I know that it needs to have something that “goes before”, and something that “goes after”, but I want the “goes before” and “goes after” to stay the same.  The two ways I know of doing that are saving the “before” and “after” in groups, which can then be referenced in the replacement; or I can use the fancy features of look-behind or match-reset for the “before” and lookahead for the “after”.</p>
<p dir="auto">The groups are often easier to understand:</p>
<ul>
<li>FIND = <code>(?i)(\$\l+)-(\l+)</code>
<ul>
<li>the <code>(?i)</code> looks like a group, but isn’t; instead, it makes sure that the match ignores case on letters</li>
<li>The other regex portions in parentheses are the groups for saving the “before” and “after”</li>
<li><code>\$\l+</code> means the literal $ followed by one or more lowercase letters – but because we told it to ignore case earlier, <code>\l</code> means any letter character.  (Originally, I used <code>\$\w+</code>, which is literal $ followed by one or more “word characters”, which is uppercase, lowercase, or underscore.  That may or may not work for you, since you never defined what characters were allowed in “replace words that begin with $”</li>
<li>the <code>\l+</code> after the - captures the letters after the -</li>
</ul>
</li>
<li>REPLACE  = <code>${1}_${2}</code>
<ul>
<li>that uses the contents of group1 (the letters before the -), then the literal <code>_</code>, then the contents of group2 (the letters after the -).  Note that some might write that as <code>$1_$2</code> or <code>\1_\2</code>, but those notation only allows groups 1 - 9; you have to include the {} if you want a group number bigger than that, or if you want to be able to put a literal digit after the match group.</li>
</ul>
</li>
<li>MODE = regular expression</li>
</ul>
<p dir="auto">Alternately, with match-reset and lookahead:</p>
<ul>
<li>FIND = <code>(?i)\$\l+\K-(?=\l+)</code>
<ul>
<li>case insensitive, find literal $, find one or more letters, reset the match (so none of those will be replaced), find the literal <code>-</code>, then look ahead to find one or more letters (but they aren’t part of the “match”</li>
</ul>
</li>
<li>REPLACE = <code>_</code>
<ul>
<li>the whole match is replaced by the <code>_</code>; since the only character in the match was the <code>-</code>, it just replaces the <code>-</code> with the <code>_</code></li>
</ul>
</li>
<li>mode = regular expression</li>
</ul>
<p dir="auto">Either of those work for me for your sample data.</p>
<p dir="auto">-—</p>
<p dir="auto"><em>Do you want regex search/replace help?  Then please be patient and polite, show some effort, and be willing to learn; answer questions and requests for clarification that are made of you.  All example text should be marked as literal text using the <code>&lt;/&gt;</code> toolbar button or manual <a href="https://community.notepad-plus-plus.org/topic/14262/how-to-markdown-code-on-this-forum/4">Markdown syntax</a>. To make <code>regex in red</code> (and so they keep their special characters like *), use backticks, like <code>`^.*?blah.*?\z`</code>. Screenshots can be pasted from the clipboard to your post using <code>Ctrl+V</code> to show graphical items, but any text should be included as literal text in your post so we can easily copy/paste your data. Show the data you have <strong>and</strong> the text you want to get from that data; include examples of things that <strong>should match</strong> and be transformed, <strong>and</strong> things that <strong>don’t match</strong> and should be left alone; show <strong>edge cases</strong> and make sure you examples are as <strong>varied</strong> as your real data.  Show the regex you already tried, <strong>and why</strong> you thought it should work; tell us what’s wrong with what you <strong>do</strong> get. Read the official <a href="https://npp-user-manual.org/docs/searching/#regular-expressions" rel="nofollow ugc">NPP Searching / Regex docs</a> and the forum’s <a href="https://community.notepad-plus-plus.org/topic/15765/faq-desk-where-to-find-regex-documentation">Regular Expression FAQ</a>. If you follow these guidelines, you’re much more likely to get helpful replies that solve your problem in the shortest number of tries.</em></p>
]]></description><link>https://community.notepad-plus-plus.org/post/62422</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/62422</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Tue, 02 Feb 2021 15:00:01 GMT</pubDate></item></channel></rss>