<?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[Looking for string search that includes the &amp; mnemonic]]></title><description><![CDATA[<p dir="auto">Hello,</p>
<p dir="auto">I work for a CAD software maker in the US as a Spanish technical translator. One of my responsibilities is to work with UI strings on Notepad++. My colleague, our localization engineer, and I have been trying to find a way to include (or ignore) the &amp; symbol in strings containing mnemonics.</p>
<p dir="auto">Why is this a problem? Because a search of <strong>Extend area</strong> (a sample command) can return Extend area and <strong>E&amp;xtend area</strong>, but we have no idea where the mnemonics in a given command are throughout our CAD software. I need to find a way to either <em>include &amp; at any position in the string</em> to capture all instances of a command, or to ignore &amp; so that the search returns cover both the command with &amp; and without &amp;. Is that possible in Notepad++?</p>
<p dir="auto">Thank you for your help.</p>
<p dir="auto">Mario Chávez, Spanish technical translator</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/24280/looking-for-string-search-that-includes-the-mnemonic</link><generator>RSS for Node</generator><lastBuildDate>Wed, 15 Jul 2026 22:17:48 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/24280.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 21 Mar 2023 15:54:21 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Looking for string search that includes the &amp; mnemonic on Sun, 26 Mar 2023 11:31:56 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/85233">Looking for string search that includes the &amp; mnemonic</a>:</p>
<blockquote>
<p dir="auto">I noticed that the search is a non-sensitive search</p>
</blockquote>
<p dir="auto">If you wanted a “sensitive” search you could add <code>(?-i)</code> to the start(s) of the expressions you input at the prompt.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/85235</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/85235</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Sun, 26 Mar 2023 11:31:56 GMT</pubDate></item><item><title><![CDATA[Reply to Looking for string search that includes the &amp; mnemonic on Sun, 26 Mar 2023 11:30:39 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/85233">Looking for string search that includes the &amp; mnemonic</a>:</p>
<blockquote>
<p dir="auto">The nice thing is that your embedded expression may contain more than 1 character</p>
</blockquote>
<p dir="auto">Yes.</p>
<p dir="auto">So that my earlier example:</p>
<p dir="auto"><code>cop&amp;amp;y</code></p>
<p dir="auto">where I want to logically search for <code>copy</code> and not worry about an “embedded” <code>&amp;amp;</code>, is handled by the script.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/85234</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/85234</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Sun, 26 Mar 2023 11:30:39 GMT</pubDate></item><item><title><![CDATA[Reply to Looking for string search that includes the &amp; mnemonic on Sun, 26 Mar 2023 11:22:26 GMT]]></title><description><![CDATA[<p dir="auto">Hello, <a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: alan-kilborn">@<bdi>alan-kilborn</bdi></a> and <strong>All</strong>,</p>
<p dir="auto">I just tried your <strong><code>Python</code></strong> script and it works <strong>nice</strong> !</p>
<p dir="auto">I noticed that the search is a <strong>non-sensitive</strong> search, which is correct as, for example, the <strong>Microsoft</strong> access keys <strong><code>&amp;e</code></strong> and <strong><code>&amp;E</code></strong> produces <strong>similar</strong> results</p>
<p dir="auto">The nice thing is that your <strong><code>embedded expression</code></strong> may contain <strong>more</strong> than <strong><code>1</code></strong> character ;-))</p>
<p dir="auto">BR</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/85233</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/85233</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Sun, 26 Mar 2023 11:22:26 GMT</pubDate></item><item><title><![CDATA[Reply to Looking for string search that includes the &amp; mnemonic on Sun, 26 Mar 2023 10:48:07 GMT]]></title><description><![CDATA[<p dir="auto">This discussion thread has reminded me of <a href="https://community.notepad-plus-plus.org/topic/21068">ANOTHER</a>.  In that other thread, I don’t think we truly achieved satisfaction.</p>
<p dir="auto">But I think in this current thread, we might be able to get satisfaction, with a script, I’ll call it <code>SearchWhileIgnoringEmbeddedExpression.py</code>:</p>
<pre><code class="language-py"># -*- coding: utf-8 -*-
from __future__ import print_function

# see https://community.notepad-plus-plus.org/topic/24280/looking-for-string-search-that-includes-the-mnemonic

from Npp import *
import inspect
import os

class SWIEE(object):

    def __init__(self):
        self.this_script_name = inspect.getframeinfo(inspect.currentframe()).filename.split(os.sep)[-1].rsplit('.', 1)[0]
        user_input = ''
        didnt_just_wrap = True
        while True:
            if didnt_just_wrap:
                user_input = self.prompt('Enter possible embedded expression          then Ctrl+Enter\r\nthen search text          then press OK to find next', user_input)
                if user_input == None: return  # user cancel
                line_list = user_input.splitlines()
                if len(line_list) != 2: continue
                possible_embedded_expr = line_list[0]
                char_list = list(line_list[1])
                embedded_portion_regex = '(?:' + possible_embedded_expr + ')?'
                search_regex = '(?i)' + embedded_portion_regex + embedded_portion_regex.join(char_list)
            match_list = []
            start_pos_for_search = editor.getCurrentPos() if didnt_just_wrap else 0
            didnt_just_wrap = True
            editor.research(search_regex, lambda m: match_list.append(m.span(0)), 0, start_pos_for_search, editor.getLength(), 1)
            if len(match_list) == 0:
                if self.yes_no('No (more) matches -- wrap around and keep searching?'):
                    didnt_just_wrap = False
                    continue
                return
            else:
                (match_start, match_end) = match_list[0]
                editor.scrollRange(match_end, match_start)
                editor.setSelection(match_end, match_start)

    def yes_no(self, question_text):  # returns True(Yes), False(No)
        answer = self.mb(question_text, MESSAGEBOXFLAGS.YESNO, self.this_script_name)
        return True if answer == MESSAGEBOXFLAGS.RESULTYES else False

    def prompt(self, prompt_text, default_text=''):
        if '\n' not in prompt_text: prompt_text = '\r\n' + prompt_text
        prompt_text += ':'
        return notepad.prompt(prompt_text, self.this_script_name, default_text)

    def mb(self, msg, flags=0, title=''):  # a message-box function
        return notepad.messageBox(msg, title if title else self.this_script_name, flags)

if __name__ == '__main__': SWIEE()
</code></pre>
<p dir="auto">If we take some data:</p>
<pre><code class="language-txt">&amp;Extended area
E&amp;xtended area
Ex&amp;tended area
Ext&amp;ended area
</code></pre>
<p dir="auto">And run the script on it, we get prompted with:</p>
<p dir="auto"><img src="/assets/uploads/files/1679827286221-bd9c123d-8423-47f8-abe5-95d78da03ae5-image.png" alt="bd9c123d-8423-47f8-abe5-95d78da03ae5-image.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">We enter:</p>
<p dir="auto"><img src="/assets/uploads/files/1679827328330-c014b884-cd39-428c-a684-ad4548721e76-image.png" alt="c014b884-cd39-428c-a684-ad4548721e76-image.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">And click OK and we are jumped to the first match:</p>
<p dir="auto"><img src="/assets/uploads/files/1679827422174-05d668f2-9fc8-4b39-80fe-191fc10fdc4b-image.png" alt="05d668f2-9fc8-4b39-80fe-191fc10fdc4b-image.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">We are reprompted to continue the search, doing so results in a match where <code>&amp;</code> is embedded <em>inside</em> the other data:</p>
<p dir="auto"><img src="/assets/uploads/files/1679827455638-83c8abc2-e726-495c-83b6-b5e0331daf02-image.png" alt="83c8abc2-e726-495c-83b6-b5e0331daf02-image.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">Continuing to press OK to the scripts prompting, we continue the search until we are out of matches.  When this occurs, we get prompted to “wrap”:</p>
<p dir="auto"><img src="/assets/uploads/files/1679827665049-42132a54-4836-46c2-80fb-21a43c85c1a3-image.png" alt="42132a54-4836-46c2-80fb-21a43c85c1a3-image.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">That’s all, folks.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/85232</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/85232</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Sun, 26 Mar 2023 10:48:07 GMT</pubDate></item><item><title><![CDATA[Reply to Looking for string search that includes the &amp; mnemonic on Fri, 24 Mar 2023 19:03:17 GMT]]></title><description><![CDATA[<p dir="auto">Hi, <a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: alan-kilborn">@<bdi>alan-kilborn</bdi></a> and <strong>All</strong>,</p>
<p dir="auto"><strong>EDIT</strong> : I modified the <strong>second</strong> line <strong><code>&lt;Item id="42037" ...</code></strong></p>
<hr />
<p dir="auto">I <strong>first</strong> verified with an <strong>old</strong> portable N++ version <strong><code>v7.2</code></strong> ! Here is an <strong>updated</strong> example with the <strong>recent</strong> <strong><code>v8.5</code></strong> release !</p>
<p dir="auto">So, for a <strong>portable</strong> version :</p>
<ul>
<li>
<p dir="auto"><strong>Start</strong> Notepad++</p>
</li>
<li>
<p dir="auto">In <strong><code>Settings &gt; Preferences... &gt; Localization</code></strong>, choose the <strong><code>English (customizable)</code></strong> option</p>
</li>
<li>
<p dir="auto">Click on the <strong><code>Close</code></strong> button</p>
</li>
</ul>
<p dir="auto">=&gt; N++ <strong>automatically</strong> creates the <strong><code>nativeLang.xml</code></strong>  file, along with all other files</p>
<ul>
<li>
<p dir="auto">Open this <strong><code>nativeLang.xml</code></strong>  file in <strong>Notepad++</strong></p>
</li>
<li>
<p dir="auto"><strong>Change</strong>, for instance, the line :</p>
</li>
</ul>
<pre><code class="language-xml">                    &lt;Item id="42037" name="Column Mode..."/&gt;
</code></pre>
<p dir="auto">with :</p>
<pre><code class="language-xml">                    &lt;Item id="42037" name="Column&amp;amp; Mode..."/&gt;
</code></pre>
<ul>
<li>
<p dir="auto"><strong>Save</strong> the modifications of the <strong><code>nativeLang.xml</code></strong> file</p>
</li>
<li>
<p dir="auto"><strong>Exit</strong> Notepad++</p>
</li>
<li>
<p dir="auto"><strong>Restart</strong> Notepad++</p>
</li>
<li>
<p dir="auto">Whatever the <strong>current</strong> tab seen, hitting, <strong>successively</strong> the keys <strong><code>Alt</code></strong>, <strong><code>E</code></strong> and <strong><code>Space bar</code></strong> should show the <strong><code>Column Mode Tip</code></strong> panel !</p>
</li>
</ul>
<p dir="auto">BR</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/85176</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/85176</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Fri, 24 Mar 2023 19:03:17 GMT</pubDate></item><item><title><![CDATA[Reply to Looking for string search that includes the &amp; mnemonic on Fri, 24 Mar 2023 11:27:45 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/85171">Looking for string search that includes the &amp; mnemonic</a>:</p>
<blockquote>
<p dir="auto">verified that putting an &amp; character, right before a space char gives a functional access key  Alt, … , …, Space bar, in Notepad++ !</p>
</blockquote>
<p dir="auto">I didn’t try it myself, but what’s the <code>... , ...</code> part of that?</p>
]]></description><link>https://community.notepad-plus-plus.org/post/85172</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/85172</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Fri, 24 Mar 2023 11:27:45 GMT</pubDate></item><item><title><![CDATA[Reply to Looking for string search that includes the &amp; mnemonic on Fri, 24 Mar 2023 13:08:03 GMT]]></title><description><![CDATA[<p dir="auto">Hello, <a class="plugin-mentions-user plugin-mentions-a" href="/user/mario-ch%C3%A1vez" aria-label="Profile: mario-chávez">@<bdi>mario-chávez</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/terry-r" aria-label="Profile: terry-r">@<bdi>terry-r</bdi></a> and <strong>All</strong>,</p>
<p dir="auto">Here is an <strong>other</strong> approach to the problem !</p>
<hr />
<p dir="auto">Let’s start with, for instance, this <em>INPUT</em> text :</p>
<pre><code class="language-diff">Extended area
</code></pre>
<p dir="auto">As it contains <strong><code>13</code></strong> characters, we’ll use this <strong>first</strong> regex S/R :</p>
<p dir="auto">SEARCH <strong><code>(?-s).+</code></strong></p>
<p dir="auto">REPLACE <strong><code>$0$0$0$0$0$0$0$0$0$0$0$0$0</code></strong>    ( <strong><code>13</code></strong> times the string <strong><code>$0</code></strong> )</p>
<p dir="auto">and we get the <strong>temporary</strong> text :</p>
<pre><code class="language-diff">Extended areaExtended areaExtended areaExtended areaExtended areaExtended areaExtended areaExtended areaExtended areaExtended areaExtended areaExtended areaExtended area
</code></pre>
<hr />
<p dir="auto">Now we’ll use this <strong>second</strong> regex S/R :</p>
<p dir="auto">SEARCH <strong><code>(?-s)(^(?=.)|.{14})\K</code></strong>    ( <strong><code>14</code></strong> = String characters <strong>count</strong> + <strong><code>1</code></strong> )</p>
<p dir="auto">REPLACE <strong><code>&amp;</code></strong></p>
<p dir="auto">And the <strong>temporary</strong> text becomes :</p>
<pre><code class="language-diff">&amp;Extended areaE&amp;xtended areaEx&amp;tended areaExt&amp;ended areaExte&amp;nded areaExten&amp;ded areaExtend&amp;ed areaExtende&amp;d areaExtended&amp; areaExtended &amp;areaExtended a&amp;reaExtended ar&amp;eaExtended are&amp;a
</code></pre>
<hr />
<p dir="auto">Finally, with this <strong>third</strong> regex S/R :</p>
<p dir="auto">SEARCH <strong><code>(?-i)^(&amp;)|(a)(?=E)</code></strong>    ( The letters <strong><code>a</code></strong> and <strong><code>E</code></strong> are, respectively, the <strong>last</strong> and the <strong>first</strong> characters of the <strong>initial</strong> string )</p>
<p dir="auto">REPLACE <strong><code>(?1\(?-i\)&amp;)?2\2|</code></strong></p>
<p dir="auto">We get the following <em>OUTPUT</em> text which can be used to search for <strong>any</strong> syntax of the <strong><code>Extended area</code></strong> string containing a <strong>single</strong> <strong><code>&amp;</code></strong> character :</p>
<pre><code class="language-diff">(?-i)&amp;Extended area|E&amp;xtended area|Ex&amp;tended area|Ext&amp;ended area|Exte&amp;nded area|Exten&amp;ded area|Extend&amp;ed area|Extende&amp;d area|Extended&amp; area|Extended &amp;area|Extended a&amp;rea|Extended ar&amp;ea|Extended are&amp;a
</code></pre>
<p dir="auto">Indeed, the following <strong>search</strong> regex :</p>
<p dir="auto">SEARCH <strong><code>(?-i)&amp;Extended area|E&amp;xtended area|Ex&amp;tended area|Ext&amp;ended area|Exte&amp;nded area|Exten&amp;ded area|Extend&amp;ed area|Extende&amp;d area|Extended&amp; area|Extended &amp;area|Extended a&amp;rea|Extended ar&amp;ea|Extended are&amp;a</code></strong></p>
<p dir="auto">matches <strong>one only</strong> of the strings below :</p>
<pre><code class="language-diff">&amp;Extended area
E&amp;xtended area
Ex&amp;tended area
Ext&amp;ended area
Exte&amp;nded area
Exten&amp;ded area
Extend&amp;ed area
Extende&amp;d area
Extended&amp; area
Extended &amp;area
Extended a&amp;rea
Extended ar&amp;ea
Extended are&amp;a
</code></pre>
<p dir="auto">Best Regards,</p>
<p dir="auto">guy038</p>
<p dir="auto"><strong>P.S.</strong> :</p>
<p dir="auto">I <strong>personally</strong> verified that putting an <strong><code>&amp;</code></strong> character, right before a <strong><code>space</code></strong> char gives a <strong>functional</strong> access key  <strong><code>Alt, ... , ..., Space bar</code></strong>, in <strong>Notepad++</strong> !</p>
]]></description><link>https://community.notepad-plus-plus.org/post/85171</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/85171</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Fri, 24 Mar 2023 13:08:03 GMT</pubDate></item><item><title><![CDATA[Reply to Looking for string search that includes the &amp; mnemonic on Wed, 22 Mar 2023 20:37:31 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/85063">Looking for string search that includes the &amp; mnemonic</a>:</p>
<blockquote>
<p dir="auto">As I say, I’m not entirely happy though that it is a much longer regex</p>
</blockquote>
<p dir="auto">Well I wasn’t happy, in the end I figured my last idea wasn’t going down the right track.</p>
<p dir="auto">I remembered an old post from <a class="plugin-mentions-user plugin-mentions-a" href="/user/peterjones" aria-label="Profile: PeterJones">@<bdi>PeterJones</bdi></a> that was to count a line length excluding specified characters, #18704. The basis of the solution lies there, so I can’t claim ownership of the idea. So Find What is (for the word <code>extended</code> with/without a <code>&amp;</code> attached to the word <code>([&amp;]*[extnd][&amp;]*){8,9}</code>. Note that if there will never be a preceding <code>&amp;</code> (no &amp;extended), rather it will always be embedded or trailing, then it can change to <code>([extnd][&amp;]*){8,9}</code> or <code>([extended][&amp;]*){8,9}</code> could also be used for ease of typing in the word. So we are back to a short regex, but at the moment it could select another word which is of the same length and uses characters within the class range, like an anagram. A method of minimising that possibility lies with using lookaheads to find both starting character and ending character of the word to identify they match. It still does not guarantee excluding a similar word which fits but should greatly minimise the chance I think. That would look something like this, <code>(?=&amp;?e[^\x20]+d)([&amp;]*[extended][&amp;]*){8,9}</code> or <code>(?=&amp;?e[^\x20]+d)((&amp;)?[extended](&amp;)?){8,9}</code>. For those unsure, the \x20 is the space character which can be entered instead.</p>
<p dir="auto">Perhaps some benefit of this solution is that the “excluded” characters could be altered to be anything and any length. All that is required is to cater for the 2 different lengths of the word and type in the correct 2 numbers trailing (i.e. {8,9}). So this idea may also help <a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: Alan-Kilborn">@<bdi>Alan-Kilborn</bdi></a> with his need. For the word “Macro” with <code>&amp;amp;</code> possibly attached to the word at any position we would have <code>"((&amp;amp;)?[macro](&amp;amp;)?){5,10}"</code>. Note I have changed the excluded characters from a class range to an optional group. So if the excluded characters were to exist they must exist in their entirety and in the same order. I’ve included the quotes as I used the english.xml file for testing. Again it will need modification in regards how it is used.</p>
<p dir="auto">At this point I think I’ve used up enough spare time on this. This will only ever be an approximation, unless a vastly more complex regex was created, which then negates the ability of novices to use and alter for different words.</p>
<p dir="auto">Terry</p>
]]></description><link>https://community.notepad-plus-plus.org/post/85105</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/85105</guid><dc:creator><![CDATA[Terry R]]></dc:creator><pubDate>Wed, 22 Mar 2023 20:37:31 GMT</pubDate></item><item><title><![CDATA[Reply to Looking for string search that includes the &amp; mnemonic on Wed, 22 Mar 2023 00:17:45 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/85058">Looking for string search that includes the &amp; mnemonic</a>:</p>
<blockquote>
<p dir="auto">iven that anagrams of Extend area are not likely to be found as other menu entries, it’s probably pretty safe.</p>
</blockquote>
<p dir="auto">As <a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: Alan-Kilborn">@<bdi>Alan-Kilborn</bdi></a> pointed out, I was doing some more thinking, specifically with regards to the “anagram” possibility.</p>
<p dir="auto">My latest regex is <code>(?=.?s.?h.?a.?p.?e)(?&lt;!\w|&amp;|\S)[shape&amp;]{5,6}(?=\W|\s)</code>. It is now starting to look a bit complex, the only benefit is that even a novice could edit it for the word replacement.</p>
<p dir="auto">For those who are having difficulty in understanding the regex we have:<br />
<code>(?=.?s.?h.?a.?p.?e)</code> - looking for the general shape of word, thus each <code>.?</code> caters for a single other character (in this case the &amp;). It’s non-specific on how many of these other characters exist, just that they can exist and in only the positions designated. this removes the anagram issue.<br />
<code>(?&lt;!\w|&amp;|\S)</code> - at the position of the caret, we want the character preceding to be <strong>none</strong> of the following, a word character, a &amp; or a non-space.<br />
<code>[shape&amp;]{5,6}</code> tries to identify 5 (or 6) characters that are made up of the characters within this class defined by the <code>[</code> and the <code>]</code>.<br />
<code>(?=\W|\s)</code> - at the position of the caret we want ahead either of the following characters, a non-word character or a space.</p>
<p dir="auto">So for another word such as <code>extended</code> we would have<br />
<code>(?=.?e.?x.?t.?e.?n.?d.?e.?d)(?&lt;!\w|&amp;|\S)[extnd&amp;]{8,9}(?=\W|\s)</code><br />
Please note that I did not type in <code>extended</code> into the <code>[]</code> class, on purpose. The <code>e</code> and <code>d</code> already exist once, there is no need to type them twice (although I could have as it would not create an error). The <code>{8,9}</code> takes care of the requirement to have the correct number of characters comprising the word we seek.</p>
<p dir="auto">Please note that this is still a “work in progress”. I’m still not entirely happy with the regex, although I am fairly sure it will not select any words not wanted.</p>
<p dir="auto">Look forward to any feedback, or even if someone else wants to take up the challenge. I’m interested to see where this might go, even to solving <a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: Alan-Kilborn">@<bdi>Alan-Kilborn</bdi></a> requirement.</p>
<p dir="auto">Terry</p>
<p dir="auto">PS  I should add that I’m aware that part of it does look very similar to <a class="plugin-mentions-user plugin-mentions-a" href="/user/peterjones" aria-label="Profile: PeterJones">@<bdi>PeterJones</bdi></a> version. There is a difference in that I think my version tightens the requirement as it specifies multiple methods of determining the correct word. As I say, I’m not entirely happy though that it is a much longer regex</p>
]]></description><link>https://community.notepad-plus-plus.org/post/85063</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/85063</guid><dc:creator><![CDATA[Terry R]]></dc:creator><pubDate>Wed, 22 Mar 2023 00:17:45 GMT</pubDate></item><item><title><![CDATA[Reply to Looking for string search that includes the &amp; mnemonic on Tue, 21 Mar 2023 20:04:32 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> ,</p>
<p dir="auto">Interesting idea.  Given that anagrams of <code>Extend area</code> are not likely to be found as other menu entries, it’s probably pretty safe.  But if <a class="plugin-mentions-user plugin-mentions-a" href="/user/mario-ch%C3%A1vez" aria-label="Profile: Mario-Chávez">@<bdi>Mario-Chávez</bdi></a> chooses to go in that direction, I’d recommend making a backup copy first, and look for unexpected matches as the search is being performed, or at least after replacements are done.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/85058</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/85058</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Tue, 21 Mar 2023 20:04:32 GMT</pubDate></item><item><title><![CDATA[Reply to Looking for string search that includes the &amp; mnemonic on Tue, 21 Mar 2023 20:03:14 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></p>
<p dir="auto">It seems an interesting approach…that I haven’t yet thought too much about.  But I wanted to share something else, as it appears you are going to do more thinking on it:</p>
<p dir="auto">A similar problem to the OP’s that I have is I often search <code>english.xml</code> in Notepad++ source code, and I’m always surprised when text I “know” is there doesn’t yield any hits.  It is inevitably because of an embedded <code>&amp;amp;</code> string somewhere.</p>
<p dir="auto">So for example, if I’m looking for <code>Save a Copy As</code> I might search for <code>copy as</code>.  And there I’m disappointed because I don’t get the hit I’m seeking; I’d have to search for <code>cop&amp;amp;y as</code> to find it.</p>
<p dir="auto">So I guess what I’m saying is, as you mature your technique, please also consider embedded <em>expressions</em> (and perhaps even embedded regular expressions??) as well as the OP’s simple single-character-embedded situation.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/85057</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/85057</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Tue, 21 Mar 2023 20:03:14 GMT</pubDate></item><item><title><![CDATA[Reply to Looking for string search that includes the &amp; mnemonic on Tue, 21 Mar 2023 19:33:47 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mario-ch%C3%A1vez" aria-label="Profile: Mario-Chávez">@<bdi>Mario-Chávez</bdi></a> said in <a href="/post/85047">Looking for string search that includes the &amp; mnemonic</a>:</p>
<blockquote>
<p dir="auto">I need to find a way to either include &amp; at any position in the string to capture all instances of a command, or to ignore &amp; so that the search returns cover both the command with &amp; and without &amp;.</p>
</blockquote>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/peterjones" aria-label="Profile: PeterJones">@<bdi>PeterJones</bdi></a> I might have found a slightly better way than having to include the <code>&amp;?</code> at every possible position. It’s still a bit rough but I’m happy to put it up for public scrutiny to see if anyone may be able to fine tune it.<br />
Find What:<code>\b[new&amp;]{3,4}\b</code> So this is to find any word that is <code>new</code> and may contain a possible &amp; in any position. For the word “extend” it would be <code>\b[extend&amp;]{6,7}\b</code>.</p>
<p dir="auto">It could potentially grab a word that contains as many characters as dictated (within the class stated) but not be the word that is being looked for but I think that would be preferable to missing any potential words.</p>
<p dir="auto">Terry</p>
]]></description><link>https://community.notepad-plus-plus.org/post/85056</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/85056</guid><dc:creator><![CDATA[Terry R]]></dc:creator><pubDate>Tue, 21 Mar 2023 19:33:47 GMT</pubDate></item><item><title><![CDATA[Reply to Looking for string search that includes the &amp; mnemonic on Tue, 21 Mar 2023 16:41:01 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mario-ch%C3%A1vez" aria-label="Profile: Mario-Chávez">@<bdi>Mario-Chávez</bdi></a> ,</p>
<p dir="auto">So, assuming you have text like</p>
<pre><code>E&amp;xtended area
&amp;New drawing
Add &amp;Shape
</code></pre>
<p dir="auto">… and you wanted to search for <code>Extend area</code> with &amp; being allowed in any of those positions, you would have to use something like <code>&amp;?E&amp;?x&amp;?t&amp;?e&amp;?n&amp;?d&amp;?e&amp;?d&amp;? &amp;?a&amp;?r&amp;?e&amp;?a&amp;?</code> , and it has to be in Regular Expression search mode for that to work.  The <code>&amp;?</code> will look for 0 or 1 instance of a literal <code>&amp;</code> in your text, so putting that before/after every character will allow &amp; to show up anywhere in the string.  Unfortunately, there’s no “easy” way to simplify if you’re looking for those.</p>
<p dir="auto">If you’re going to have multiple of those, like searching for <code>New drawing</code> and <code>Add Shape</code> later, I’d probably set up a dummy file which has all of the raw text, like</p>
<pre><code>Extended area
New drawing
Add &amp;Shape
</code></pre>
<p dir="auto">… then do a regex search/replace to generate your regex:</p>
<ul>
<li>FIND = <code>(^|[\h\w])(?!&amp;)</code> – look for beginning of line, or any horizontal space or alphanumeric that isn’t followed by an <code>&amp;</code></li>
<li>REPLACE = <code>$0&amp;?</code> – replace with that original string and then <code>&amp;?</code></li>
<li>Search Mode = Regular Expression</li>
<li>Replace All</li>
</ul>
<p dir="auto">This will create a list of regex, like</p>
<pre><code>&amp;?E&amp;?x&amp;?t&amp;?e&amp;?n&amp;?d&amp;?e&amp;?d&amp;? &amp;?a&amp;?r&amp;?e&amp;?a&amp;?
&amp;?N&amp;?e&amp;?w&amp;? &amp;?d&amp;?r&amp;?a&amp;?w&amp;?i&amp;?n&amp;?g&amp;?
&amp;?A&amp;?d&amp;?d&amp;? &amp;S&amp;?h&amp;?a&amp;?p&amp;?e&amp;?
</code></pre>
<p dir="auto">You can then copy each of those regex and paste into FIND WHAT, then go into your real document, and do the search.</p>
<p dir="auto">Alternately, if you don’t care about remembering where the <code>&amp;</code> was falling in the English strings, and just want the raw English strings for easily translating to Spanish, and then you’ll later manually add in <code>&amp;</code> where it makes sense for Spanish, I might suggest to just replace <code>&amp;</code> with the empty string in the English source, then you’d just have raw English for translating.</p>
<p dir="auto">You might also consider looking into using my “translation bot” script for the PythonScript plugin, found <a href="https://community.notepad-plus-plus.org/post/77068">in this post</a>. You could then have the left side of the translation table be the complicated regex with all the <code>&amp;?</code> already inserted, and the right be the Spanish equivalents, putting your single &amp; wherever it should go in the Spanish, like</p>
<pre><code class="language-py">translation = {
    r'&amp;?E&amp;?x&amp;?t&amp;?e&amp;?n&amp;?d&amp;?e&amp;?d&amp;? &amp;?a&amp;?r&amp;?e&amp;?a&amp;?':               r'Área e&amp;Xtendida',
    r'&amp;?N&amp;?e&amp;?w&amp;? &amp;?d&amp;?r&amp;?a&amp;?w&amp;?i&amp;?n&amp;?g&amp;?':                     r'&amp;Nuevo dibujo',
    r'&amp;?A&amp;?d&amp;?d&amp;? &amp;S&amp;?h&amp;?a&amp;?p&amp;?e&amp;?':                            r'Agregar &amp;Forma',
}
</code></pre>
<p dir="auto">(caveat: that was just my simple Google-translate for the three English phrases; I have no clue if those are the common Spanish idioms for those menu commands, and I make no guarantee or warranty as to the usefulness of those translations.)</p>
<p dir="auto">All the regex above assume simple text requirements. If you’ve got a complicated mix where you want some of the &amp; in your text to remain unedited and others to be found/replaced, you’re going to have to make the regex more complicated than I showed.  Just keep in mind that <code>&amp;?</code> means 0-or-1-<code>&amp;</code> and you need that in any position in the regex where you might find a <code>&amp;</code> or might not.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/85049</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/85049</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Tue, 21 Mar 2023 16:41:01 GMT</pubDate></item></channel></rss>