<?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 help: Find&#x2F;Replace only on lines that include specific words]]></title><description><![CDATA[<p dir="auto">First, I’m not native English speaker and the sentences I write might be wrong, so feel free to ask me if you don’t understand my question.</p>
<p dir="auto">Ok…<br />
I have text files with tons of sentences.<br />
Like<br />
.<br />
.<br />
~~list([“Apple”, “Banana”, “Orange”])<br />
~~choice([“Red”, “Blue”, “Orange”, … ,“Purple”])<br />
~~screen(“fruit_image”, _choice[1], )<br />
~~action Return([“category”, “fruits”])<br />
And tens of thousands of other sentences…<br />
.<br />
.</p>
<p dir="auto">And what I want to do is replace only “words” in choice([]) to (“words”)<br />
Ex) choice([“Red”, “Blue”, “Orange”, … ,“Purple”])  --&gt; choice([(“Red”), (“Blue”), (“Orange”),…,(“Purple”)])</p>
<p dir="auto">I need to change only “words” inside the choice([]) and not inside the list([]), screen([]), etc.</p>
<p dir="auto">So this is the question I want to ask.</p>
<p dir="auto"><strong>1. What regular expression should I use to do that?</strong><br />
I’ve used some regex, but I couldn’t find just the parts I wanted…  The biggest problem is that I still only understand a little bit of the regular expression. I’ve been studying recently, but it’s still so hard…😭😭</p>
<p dir="auto"><strong>2. Is there a way to find/replace only within the bookmarked line?</strong><br />
If that is possible, I can solve the problem by bookmarking only the lines containing ‘choice’ and replacing (“.<em>?") or (?=.</em>?]))(”.*?") with ($1).</p>
<p dir="auto"><strong>3. Or is there a way to select all search results or to find/replace in the search results?</strong><br />
Then, I can solve the problem by using the ‘find in selection’ function…</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/21972/regex-help-find-replace-only-on-lines-that-include-specific-words</link><generator>RSS for Node</generator><lastBuildDate>Wed, 13 May 2026 21:57:21 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/21972.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 14 Oct 2021 08:15:46 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Regex help: Find&#x2F;Replace only on lines that include specific words on Sun, 17 Oct 2021 05:52:59 GMT]]></title><description><![CDATA[<p dir="auto">Hi, <a class="plugin-mentions-user plugin-mentions-a" href="/user/%EB%B9%84%EA%B3%B5%EA%B0%9C" aria-label="Profile: 비공개">@<bdi>비공개</bdi></a>, <a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: alan-kilborn">@<bdi>alan-kilborn</bdi></a>, <a class="plugin-mentions-user plugin-mentions-a" href="/user/neil-schipper" aria-label="Profile: Neil-schipper">@<bdi>Neil-schipper</bdi></a> and <strong>All</strong>,</p>
<p dir="auto">OK, <a class="plugin-mentions-user plugin-mentions-a" href="/user/%EB%B9%84%EA%B3%B5%EA%B0%9C" aria-label="Profile: 비공개">@<bdi>비공개</bdi></a>, I’m going to give some <strong>pieces</strong> of information but, as <strong>always</strong> :</p>
<blockquote>
<ul>
<li>
<p dir="auto">You have to know how to make cement before you can put two bricks together</p>
</li>
<li>
<p dir="auto">You must know how to put two bricks together before building a wall</p>
</li>
<li>
<p dir="auto">You must know how to build a wall before building a room</p>
</li>
<li>
<p dir="auto">You must know how to build a room before building a house</p>
</li>
</ul>
</blockquote>
<p dir="auto">and so on !</p>
<p dir="auto">In other words, check this <a href="https://community.notepad-plus-plus.org/topic/15765/faq-desk-where-to-find-regular-expressions-regex-documentation">FAQ</a> which gives you the <strong>main</strong> links to learn <strong>regular</strong> expressions, from <strong>top</strong> to <strong>bottom</strong> ;-))</p>
<p dir="auto">Now, let’s go :</p>
<pre><code class="language-z">----------------------------------------------------------------------------------------------------------------------------------------------------------

Regarding MODIFIERS, generally met at BEGINNING of the regex, but which may occur at ANY location within the overall regex :

(?-i)   From this point, search      care      about letter's CASE

(?i)    From this point, search  does NOT care about letter's CASE

	      
(?-s)   From this point, any regex dot symbol represents a SINGLE STANDARD character. So the . is UNICODE equivalent to the NEGATIVE class character
              [^\r\n\f\x{0085}\x{2028}\x{2029}] for an Unicode encoded file and equivalent to [^\r\n\f] for an ANSI encoded file
	      
(?s)    From this point, any regex DOT symbol represents ABSOLUTELY ANY character, included all the LINE-ENDING chars
	      

(?-x)   From this point, any LITERAL SPACE character is SIGNIFICANT and is part of the overall regex ( IMPLICIT in a N++ regex )

(?x)    From this point, any LITERAL SPACE character is IGNORED  and just helps READABILITY of the overall regex.
             This mode is called FREE-SPACING mode and can SPLIT in SEVERAL lines. In this  mode :

             - Any SPACE char must be written [ ] or \x20  or escaped with a \ character
             - Any text, after a # symbol, will be considered as COMMENTS
             - Any litteral # symbol must be written [#] or \x23 or escaped as \#

	      
(?-m)   From this point :
             - The regex symbol ^ represents only  the VERY BEGINNING of the file, so equivalent to the regex \A
             - The regex symbol $ represents only  the VERY END       of the file, so equivalent to the regex \z
	      
(?m)    From this point, the assertions ^ and $ represent their USUAL signification of START and END of line locations ( IMPLICIT in a N++ regex )

----------------------------------------------------------------------------------------------------------------------------------------------------------

Regarding GROUPS :

(•••••)    It defines a CAPTURING group which allows, both :

               - The regex engine to STORE the regex ENCLOSED part for FURTHER use, either in the SEARCH and/or the REPLACE part

               - The regex ENCLOSED part to be possibly REPEATED with a  QUANTIFIER, located right after

(?:•••••)  It defines a NON-CAPTURING group which only allows the regex ENCLOSED part to be REPEATED and which is **not** stored by the regex engine

Note that the MODIFIERS, described above, may be INCLUDED within the parentheses :

             - In a CAPTURING group as, for instance, ((?i)•••••) so that the INSENSITIVE search is RESTRICTED to the contents of this group, only

             - In a NON-CAPTURING group, TWO syntaxes are possible : for instance : (?:(?i)•••••) or the shorthand (?i:•••••)


CAPTURING groups can be RE-USED with the syntax :

    - \1   to \9     in the SEARCH and/or REPLACE regexes   for reference to group 1 to  9
    - $1   to $99    in the REPLACE regex ONLY              for reference to group 1 to 99
    - ${1} to ${99}  in the REPLACE regex ONLY              for reference to group 1 to 99

	    For instance, the ${1}5 syntax means contents of GROUP 1 , followed with digit 5 where as the $15 syntax would have meant contents of GROUP 15
				  
    - $0 or ${0}     in the REPLACE regex ONLY              for reference to the OVERALL math of the SEARCH regex

----------------------------------------------------------------------------------------------------------------------------------------------------------

Regarding QUANTIFIERS, 6 syntaxes are possible {n} , {n,}, {n,m}, ?, + and *. Note that :

    - {n}   EXACTLY n       times the character or group, PRECEDING the quantifier
    - {n,}  n or MORE       times the character or group, PRECEDING the quantifier
    - {n,m} BETWEEN n and m times the character or group, PRECEDING the quantifier

    - ? is equivalent to {0,1}
    - + is equivalent to {1,}
    - * is equivalent to {0,}

They are considered as GREEDY quantifiers because they match as MANY characters as possible

If these 6 syntaxes are followed with a QUESTION MARK ?, they are called LAZY quantifiers because they match as FEW characters as possible
    
For instance, given the following sentence :
                                                            The licenses for most software are designed to take away your freedom to share and change it
- Regex (?-s)e.+?ar, with the LAZY   quantifier +?, matches   ---------------------------
- Regex (?-s)e.+ar , with the GREEDY quantifier +,  matches   ---------------------------------------------------------------------------


If theses 6 syntaxes are followed with a ADDITION sign +, they are called ATOMIC quantifiers.

   - They are quite similar to their GREEDY forms, exceot that, in case of failure, they don't backtrack to attempt further possible match(es)

   - Note that this ADVANCED option should be studied when you'll be rather ACQUAINTED with regexes !

----------------------------------------------------------------------------------------------------------------------------------------------------------

BTW, a quick tip to SIMULATE a NORMAL search when the REGULAR EXPRESSION mode is selected : START the search zone with the \Q syntax :

    For instance, the regex \Q/* This is a C-comment */ will find the LITERAL string  /* This is a C-comment */

</code></pre>
<hr />
<p dir="auto">Now, I will rewrite my <strong>last</strong> regex, with your <strong>improvement</strong>, in the <strong><code>Free-Spacing</code></strong> mode :</p>
<pre><code class="language-z">----------------------------------------------------------------------------------------------------------------------------------------------------------

(?x-is)                #  FREE-SPACING mode, search SENSITIVE to CASE and DOT regex symbol represents a SINGLE STANDARD char
(?:                    #  BEGINNING of a NON-CAPTURING group
~~choice               #       Matches the string ~~choice, with this EXACT case
|                      #    OR ( ALTERNATION symbol )
(?!\A)\G               #       Matches from RIGHT AFTER the location of the LAST match, IF NOT at the VERY BEGINNING of the file
)                      #  END of the NON-CAPTURING group
.+?                    #  The SMALLEST NON-NULL range of STANDARD characters till...
\K                     #  CURRENT match is DISCARDED and working location is RESET to this POINT
(?&lt;!\()                #  ONLY if it's NOT PRECEDED with a STARTING parenthesis symbol
"[!'.?\w-]+"           #  ... a NON-NULL range of WORD chars or the characters !, ', ., ? and -
(?!\))                 #  ONLY if it's NOT FOLLOWED with an ENDING parenthesis symbol


NOTES :

- This syntax is totally FUNCTIONAL. To be convinced do a NORMAL selection from (?x-is) to ENDING parenthesis symbol and hit the Ctrl + F shortcut
     =&gt; This MULTI- lines regex is AUTOMATICALLY inserted in the 'Search what' zone 

- The \G assertion means that the NEXT search must start, necessarily, RIGHT AFTER the LAST match !

- I rewrote your regex part [A-Za-z \-\.\!\?'] as [!'.?\w-] because most of the punctuation signs do NOT need to be ESCAPED, within a CLASS character.

    - However note that the DASH - must be found at the VERY BEGINNING or the VERY END of the class character, when NON escaped
    - I prefer the \w syntax to [A-Za-z] because \w also INClUDES all the ACCENTUATED characters of foreign languages

- You must use ONLY the REPLACE ALL button ( Do NOT click on the REPLACE button for SUCCESSIVE replacements : it won't work due to the \K syntax ! )

- If you don't tick the WRAP AROUND option, move preferably the CARET at the VERY BEGINNING of current file

- From BEGINNING of file, as the regex engine must SKIP some LINE-ENDING characters to get a match, the \G assertion is NOT verified

    and the regex engine must necessarily look, FIRST, for a string ~~choice

- Then, from RIGHT AFTER the word choice, it grasps the SMALLEST NON-NULL range of STANDARD chars .+? till a "•••••" structure, but ONLY IF NOT embedded
      between PARENTHESES itself !

- And, due to the \K syntax, ONLY the part "•••••" is the FINAL match desired

- This FINAL part is changed with the REPLACE regex \($0\) which just rewrites the string "•••••" between PARENTHESES.
    The parenthesis symbols must be ESCAPED as they have a SPECIAL signification in REPLACEMENT

- Then, from RIGHT AFTER the closing " char, as the regex CANNOT find any other ~~choice string, the (?!\A)\G.+? part, again, selects the SMALLEST NON-NULL
    range of STANDARD characters till an OTHER block "•••••", execute the REPLACEMENT and so on...

</code></pre>
<hr />
<p dir="auto">In the <strong>example</strong>, below, in each <strong>second</strong> line ( Regex types ) :</p>
<ul>
<li>
<p dir="auto">The <strong>dot</strong> <strong><code>.</code></strong> represents <strong>any</strong> char, found by the regex <strong>dummy</strong> part <strong><code>.+?</code></strong></p>
</li>
<li>
<p dir="auto">The <strong>bullet</strong> <strong><code>•</code></strong> represents <strong>any</strong> char, found by the regex <strong>useful</strong> part <strong><code>[!'.?\w-]</code></strong></p>
</li>
<li>
<p dir="auto">The character <strong><code>"</code></strong> and the string <strong><code>~~choice</code></strong> stand for <strong>themselves</strong></p>
</li>
</ul>
<pre><code class="language-diff">Text  processed          ~~choice(["Red", ("Blue"), ("Orange"), … ,"Purple"])
Regex types              ~~choice.."•••"..........................."••••••"
Match number BEFORE \K   1111111111     222222222222222222222222222
Match number AFTER  \K             11111                           22222222


Text  processed          ~~choice([("Red"), "Blue", "Orange", … ,("Purple")])
Regex types              ~~choice..........."••••".."••••••"
Match number BEFORE \K   1111111111111111111      22        
Match number AFTER  \K                      111111  22222222


Text  processed          ~~choice(["Red", "Blue", "Orange", … ,"Purple"])
Regex types              ~~choice.."•••".."••••".."••••••"....."••••••"
Match number BEFORE \K   1111111111     22      33        44444        
Match number AFTER  \K             11111  222222  33333333     44444444
</code></pre>
<p dir="auto">I hope that you’ll find this article <strong>useful</strong>, in any way !</p>
<p dir="auto">However, let me add that the <strong><code>\G</code></strong> and <strong><code>\K</code></strong> <strong>assertions</strong>, as well as <strong>atomic</strong> groups and <strong>recursive</strong> regexes or <strong>backtracking</strong> verbs ( not discussed ), are <strong>difficult</strong> notions and I can assure you that there are a LOT of <strong>regex</strong> things that you need to know <strong>before</strong> starting to use them !</p>
<p dir="auto">Best Regards,</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/70509</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/70509</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Sun, 17 Oct 2021 05:52:59 GMT</pubDate></item><item><title><![CDATA[Reply to Regex help: Find&#x2F;Replace only on lines that include specific words on Fri, 15 Oct 2021 02:40:38 GMT]]></title><description><![CDATA[<p dir="auto">There are many answers while I’m sleeping. Thank you so much <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/neil-schipper" aria-label="Profile: Neil-Schipper">@<bdi>Neil-Schipper</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">OK, so <a class="plugin-mentions-user plugin-mentions-a" href="/user/guy038" aria-label="Profile: guy038">@<bdi>guy038</bdi></a>, as soon as I woke up, I tried your method and it solved my problem <strong>perfectly</strong>!😀😀😀</p>
<p dir="auto">The “words” I’m looking for aren’t just written as “word charactors”, so I just changed <code>\w</code> to <code>[A-Za-z \-\.\!\?']</code>. The example I held was not appropriate. I’m sorry.</p>
<p dir="auto">And please! I need your explain.<br />
Especially, I’m not sure what <code>(?:choice|(?!\A)\G)</code> and <code>.+?\K"</code> mean.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/70504</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/70504</guid><dc:creator><![CDATA[비공개]]></dc:creator><pubDate>Fri, 15 Oct 2021 02:40:38 GMT</pubDate></item><item><title><![CDATA[Reply to Regex help: Find&#x2F;Replace only on lines that include specific words on Thu, 14 Oct 2021 16:09:06 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> Following your instructions, this works exactly as you say.</p>
<p dir="auto">Furthermore, I see now that your earlier search string also works with <em>Replace All</em> (which I hadn’t tried) but adds the unwanted extra sets of <code>()</code>.</p>
<p dir="auto">Furthermore, I also see now that my original search string (my first post in this thread) also works with <em>Replace All</em> (which I also hadn’t tried) but with the requirement for successive runs to get the whole job done as I had stated.</p>
<p dir="auto">It appears there’s something about <code>\K</code> that I don’t understand, unless it’s something not fully described in the docs but that was discovered by trial and error.</p>
<p dir="auto">I do consider it a weakness (of both of our search strings) that single replaces don’t work.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/70490</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/70490</guid><dc:creator><![CDATA[Neil Schipper]]></dc:creator><pubDate>Thu, 14 Oct 2021 16:09:06 GMT</pubDate></item><item><title><![CDATA[Reply to Regex help: Find&#x2F;Replace only on lines that include specific words on Thu, 14 Oct 2021 14:54:26 GMT]]></title><description><![CDATA[<p dir="auto">Hello, <a class="plugin-mentions-user plugin-mentions-a" href="/user/%EB%B9%84%EA%B3%B5%EA%B0%9C" aria-label="Profile: 비공개">@<bdi>비공개</bdi></a>, <a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: alan-kilborn">@<bdi>alan-kilborn</bdi></a>, <a class="plugin-mentions-user plugin-mentions-a" href="/user/neil-schipper" aria-label="Profile: Neil-schipper">@<bdi>Neil-schipper</bdi></a> and <strong>All</strong>,</p>
<p dir="auto">Ah…OK, <strong>Neil</strong>. So I improved my regex S/R in order that it will <strong>not</strong> process anything if the <strong>double</strong> quotes are already <strong>preceded</strong> and <strong>followed</strong> with parentheses !</p>
<p dir="auto">Here is the <strong>new</strong> version :</p>
<p dir="auto">SEARCH <strong><code>(?-is)(?:~~choice|(?!\A)\G).+?\K(?&lt;!\()"\w+"(?!\))</code></strong></p>
<p dir="auto">REPLACE <strong><code>\($0\)</code></strong></p>
<p dir="auto">Taking your <strong>INPUT</strong> text in account :</p>
<pre><code class="language-diff">~~list(["Apple", "Banana", "Orange"])
~~choice(["Red", "Blue", "Orange", … ,"Purple"])
~~choice(["Red", ("Blue"), ("Orange"),…,("Purple")])
~~choice([("Red"), "Blue", ("Orange"),…,("Purple")])
~~choice([("Red"), ("Blue"), "Orange",…,("Purple")])
~~choice(["Red", "Blue", "Orange", … ,"Purple"])
~~screen("fruit_image", _choice[1], )
~~action Return(["category", "fruits"])
choice([("Red"), ("Blue"), ("Orange"),…,("Purple")])
</code></pre>
<p dir="auto">It correctly changes it as below :</p>
<pre><code class="language-diff">~~list(["Apple", "Banana", "Orange"])
~~choice([("Red"), ("Blue"), ("Orange"), … ,("Purple")])
~~choice([("Red"), ("Blue"), ("Orange"),…,("Purple")])
~~choice([("Red"), ("Blue"), ("Orange"),…,("Purple")])
~~choice([("Red"), ("Blue"), ("Orange"),…,("Purple")])
~~choice([("Red"), ("Blue"), ("Orange"), … ,("Purple")])
~~screen("fruit_image", _choice[1], )
~~action Return(["category", "fruits"])
choice([("Red"), ("Blue"), ("Orange"),…,("Purple")])
</code></pre>
<hr />
<p dir="auto"><strong>Notes</strong> :</p>
<ul>
<li>
<p dir="auto">You must use <strong>only</strong> the <strong><code>Replace All</code></strong> button ( Do <em>NOT</em> click on the <strong><code>Replace</code></strong> button for <strong>successive</strong> replacements : it won’t work due to the <strong><code>\K</code></strong> syntax ! )</p>
</li>
<li>
<p dir="auto">If you don’t tick the <strong><code>Wrap around</code></strong> option, move preferably the <strong>caret</strong> at the <strong>very beginning</strong> of current file</p>
</li>
<li>
<p dir="auto">This <strong>new</strong> version avoids the formation of forms such as <strong><code>((((("text")))))</code></strong>, if you’re trying to execute this regex S/R <strong>several</strong> times !</p>
</li>
</ul>
<p dir="auto">BR</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/70485</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/70485</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Thu, 14 Oct 2021 14:54:26 GMT</pubDate></item><item><title><![CDATA[Reply to Regex help: Find&#x2F;Replace only on lines that include specific words on Thu, 14 Oct 2021 14:26:09 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> It didn’t work for me. I ran it on this test text:</p>
<pre><code>~~list([“Apple”, “Banana”, “Orange”])
~~choice([“Red”, “Blue”, “Orange”, … ,“Purple”])
~~choice([“Red”, (“Blue”), (“Orange”),…,(“Purple”)])
~~choice([(“Red”), “Blue”, (“Orange”),…,(“Purple”)])
~~choice([(“Red”), (“Blue”), “Orange”,…,(“Purple”)])
~~choice([“Red”, “Blue”, “Orange”, … ,“Purple”])
~~screen(“fruit_image”, _choice[1], )
~~action Return([“category”, “fruits”])
choice([(“Red”), (“Blue”), (“Orange”),…,(“Purple”)])
</code></pre>
<p dir="auto">and after seeing your P.S. I converted the fancy qm’s to standard ascii:</p>
<pre><code>~~list(["Apple", "Banana", "Orange"])
~~choice(["Red", "Blue", "Orange", … ,"Purple"])
~~choice(["Red", ("Blue"), ("Orange"),…,("Purple")])
~~choice([("Red"), "Blue", ("Orange"),…,("Purple")])
~~choice([("Red"), ("Blue"), "Orange",…,("Purple")])
~~choice(["Red", "Blue", "Orange", … ,"Purple"])
~~screen("fruit_image", _choice[1], )
~~action Return(["category", "fruits"])
choice([("Red"), ("Blue"), ("Orange"),…,("Purple")])
</code></pre>
<p dir="auto">but I still get no matches.</p>
<p dir="auto">I didn’t analyze your search string, and I have no doubt it’s based on sound principles.</p>
<p dir="auto">I am amazed to learn about the quotation marks getting altered. That’s another “gotcha” that warrants documentation in an easily found location! (Maybe it’s a feature than can be disabled.)</p>
<p dir="auto">Also the codes for the qm’s you state are different from mine. I got mine (lazily) by running a conversion using the <em>Converter</em> plug-in, which I have not vetted for byte-level correctness against standard character tables. Yet another trap for the unwary?</p>
]]></description><link>https://community.notepad-plus-plus.org/post/70483</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/70483</guid><dc:creator><![CDATA[Neil Schipper]]></dc:creator><pubDate>Thu, 14 Oct 2021 14:26:09 GMT</pubDate></item><item><title><![CDATA[Reply to Regex help: Find&#x2F;Replace only on lines that include specific words on Thu, 14 Oct 2021 14:55:32 GMT]]></title><description><![CDATA[<p dir="auto">Hello, <a class="plugin-mentions-user plugin-mentions-a" href="/user/%EB%B9%84%EA%B3%B5%EA%B0%9C" aria-label="Profile: 비공개">@<bdi>비공개</bdi></a>, <a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: alan-kilborn">@<bdi>alan-kilborn</bdi></a>, <a class="plugin-mentions-user plugin-mentions-a" href="/user/neil-schipper" aria-label="Profile: Neil-schipper">@<bdi>Neil-schipper</bdi></a> and <strong>All</strong>,</p>
<p dir="auto">Thanks for trying to get the solution by <strong>yourself</strong> !</p>
<p dir="auto">I’ve already found out a <strong>suitable</strong> regex S/R for your case ! Try this <strong>version</strong> and tell me if it avoids the mentioned <strong>side-effects</strong> !</p>
<p dir="auto">SEARCH <strong><code>(?-is)(?:~~choice|(?!\A)\G).+?\K"\w+"</code></strong></p>
<p dir="auto">REPLACE <strong><code>\($0\)</code></strong></p>
<p dir="auto">If <strong>OK</strong>, I could give your some <strong>regex</strong> explanations next time !</p>
<p dir="auto">Best Regards,</p>
<p dir="auto">guy038</p>
<p dir="auto"><strong>P.S.</strong> :</p>
<p dir="auto">I supposed that your file contains only regular <strong>double quotes</strong> <strong><code>"</code></strong> and <strong>not</strong> the <strong><code>“</code></strong> and <strong><code>”</code></strong> characters, of <strong>Unicode</strong> value <strong><code>\x{201C}</code></strong> and <strong><code>\x{201D}</code></strong>, which are <strong>automatically</strong> displayed in our <strong>forum</strong> !</p>
]]></description><link>https://community.notepad-plus-plus.org/post/70479</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/70479</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Thu, 14 Oct 2021 14:55:32 GMT</pubDate></item><item><title><![CDATA[Reply to Regex help: Find&#x2F;Replace only on lines that include specific words on Thu, 14 Oct 2021 13:40:13 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/neil-schipper" aria-label="Profile: Neil-Schipper">@<bdi>Neil-Schipper</bdi></a> My suggestion that the failure to replace the captured text is related to the fancy quotation marks is probably wrong because I could easily match-and-capture <code>(“Blue”)</code> and replace it with <code>\(\1\)</code> which gave the expected results.</p>
<p dir="auto">So maybe the problem is related to my use of \K.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/70477</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/70477</guid><dc:creator><![CDATA[Neil Schipper]]></dc:creator><pubDate>Thu, 14 Oct 2021 13:40:13 GMT</pubDate></item><item><title><![CDATA[Reply to Regex help: Find&#x2F;Replace only on lines that include specific words on Thu, 14 Oct 2021 13:07:32 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/%EB%B9%84%EA%B3%B5%EA%B0%9C" aria-label="Profile: 비공개">@<bdi>비공개</bdi></a> I have an incomplete solution based on this strategy:</p>
<p dir="auto">For each hit we want to match:</p>
<pre><code class="language-txt">"choice(" followed by..
any stuff, until you bump into..
space or comma or left brace, followed immediately by..
NOT "("
(and issue a match reset) 
followed by..
a word inside fancy quotation marks
(and this last text going into capture group 1)
</code></pre>
<p dir="auto">The search string is: <code>(?&lt;=choice\().*?[ ,\\[](?&lt;!\()\K(\“\w+\”)</code></p>
<p dir="auto">(I hope it appears that after the comma there’s ONE backslash before the left brace).</p>
<p dir="auto">I found this matches what (I think) you want – well, I <em>think</em> it matches because the editor highlights it.</p>
<p dir="auto">(Also, the backslashes escaping the fancy quotation marks appear to be optional.)</p>
<p dir="auto">The replace text I used: <code>\(\1\)</code></p>
<p dir="auto">Here’s the big problem: the matched text doesn’t get replaced. I need a guru to explain to me why this is so.</p>
<p dir="auto">My guess is that the problem is related to the fact that the fancy quotation marks are each three bytes long: E2809C and E2809D.</p>
<p dir="auto">Another weakness of my solution is that (if replace worked) it only processes the first text meeting the criteria on a line, so you’d need to run “replace all” a bunch of times. (I think there are ways of overcoming this, resetting and backtracking, but I haven’t looked closely into that.)</p>
]]></description><link>https://community.notepad-plus-plus.org/post/70474</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/70474</guid><dc:creator><![CDATA[Neil Schipper]]></dc:creator><pubDate>Thu, 14 Oct 2021 13:07:32 GMT</pubDate></item><item><title><![CDATA[Reply to Regex help: Find&#x2F;Replace only on lines that include specific words on Thu, 14 Oct 2021 12:14:48 GMT]]></title><description><![CDATA[<p dir="auto">Thank you <a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: Alan-Kilborn">@<bdi>Alan-Kilborn</bdi></a>😀<br />
I made regex after looking at the linked post, and it ‘almost’ seems to work well…</p>
<p dir="auto">Find: <code>(?i-s)(?:choice\(\[|\G).*?\K(?=.*?\]\))(".*?")</code><br />
Replaced by: <code>\($1\)</code></p>
<p dir="auto">I think it found every “words” in choice([]), so my problem was solved.<br />
But there was one exception, it also found the code below.</p>
<p dir="auto"><code>screen dropdown_menu(pos=(0, 0), name="", spacing=0, items_offset=(0, 0), background="#00000080", style="empty", iconset=["▾", "▴"]):</code></p>
<p dir="auto"><img src="/assets/uploads/files/1634213087878-3.png" alt="3.PNG" class=" img-fluid img-markdown" /></p>
<p dir="auto">Can you tell me why that code was found as well?<br />
I want to know what the problem of regex I made is.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/70473</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/70473</guid><dc:creator><![CDATA[비공개]]></dc:creator><pubDate>Thu, 14 Oct 2021 12:14:48 GMT</pubDate></item><item><title><![CDATA[Reply to Regex help: Find&#x2F;Replace only on lines that include specific words on Thu, 14 Oct 2021 11:01:40 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/%EB%B9%84%EA%B3%B5%EA%B0%9C" aria-label="Profile: 비공개">@<bdi>비공개</bdi></a></p>
<p dir="auto">The answers to your questions 2 and 3 is “no” and “no”.</p>
<p dir="auto">For question number 1, there is a technique presented <a href="https://community.notepad-plus-plus.org/post/62131">HERE</a> for solving that.  Have a read and see if you can apply that technique.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/70472</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/70472</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Thu, 14 Oct 2021 11:01:40 GMT</pubDate></item></channel></rss>