<?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[How to: Match Nested Pairs closed by END]]></title><description><![CDATA[<p dir="auto"><strong>Context:</strong> functionList for MATLAB</p>
<p dir="auto">The php documentation shows a PCRE regex, <code>\( ( (?&gt;[^()]+) | (?R) )* \)</code>,  which solves the problem of matching a string in parentheses, allowing for unlimited nested parentheses. This regex works as expected in N++.</p>
<p dir="auto">Question is, can this regex be modified to take strings, e.g <code>properties,methods,if,for,while</code> etc., as opening symbols and <code>end</code> as closing symbol. I failed.</p>
<p dir="auto">Example: match <code>if ... matching end</code> of <code>if a, b, for a, b, while a, b, end, end, end, more text</code></p>
]]></description><link>https://community.notepad-plus-plus.org/topic/13539/how-to-match-nested-pairs-closed-by-end</link><generator>RSS for Node</generator><lastBuildDate>Wed, 19 Aug 2026 02:05:42 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/13539.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 27 Mar 2017 21:00:29 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to How to: Match Nested Pairs closed by END on Sun, 02 Apr 2017 11:07:56 GMT]]></title><description><![CDATA[<p dir="auto">Hi <a class="plugin-mentions-user plugin-mentions-a" href="/user/guy038" aria-label="Profile: guy038">@<bdi>guy038</bdi></a>,</p>
<p dir="auto">Thanks for sending “A01466.headed.xml.txt”.<br />
Confirming your findings with some additions, note the influence of “wrap around”.<br />
Tested on a Desktop running Windows XP Home + Sp3 with Windows Classic GUI ;-)<br />
Need to get my Windows 10 x64 ready to be able to dig in and debug this!</p>
<hr />
<p dir="auto">Regex <strong>A</strong>: <code>(?si)(?&lt;=\W)(man_n)((?:\W+\w+){0,50}\W+)(city_n)(?=\W)|(?&lt;=\W)(?3)(?2)(?1)(?=\W)</code><br />
<em>and</em><br />
Regex <strong>B</strong>: <code>(?si)(?&lt;=\W)man_n(?:\W+\w+){0,50}\W+city_n(?=\W)|(?&lt;=\W)city_n(?:\W+\w+){0,50}\W+man_n(?=\W)</code><br />
<em>and</em><br />
Regex <strong>D</strong>: <code>(?si)(?&lt;=\W)city_n(?:\W+\w+){0,50}\W+man_n(?=\W)|(?&lt;=\W)man_n(?:\W+\w+){0,50}\W+city_n(?=\W)</code></p>
<p dir="auto">Pass i.e. one match even after repeated search:</p>
<ol>
<li>Find w/  wrap around;</li>
<li>Using RegexTester (by <a class="plugin-mentions-user plugin-mentions-a" href="/user/claudia-frank" aria-label="Profile: Claudia-Frank">@<bdi>Claudia-Frank</bdi></a>);</li>
<li>Using RegexBuddy w/ boost::regex 1.58-1.59 ECMAScript (default) flavor</li>
</ol>
<p dir="auto"><strong>FAIL</strong>:</p>
<ol>
<li>Find w/o wrap around - “Can’t find text”</li>
</ol>
<hr />
<p dir="auto">Regex <strong>C</strong>: <code>(?si)(?&lt;=\W)(city_n)((?:\W+\w+){0,50}\W+)(man_n)(?=\W)|(?&lt;=\W)(?3)(?2)(?1)(?=\W)</code><br />
<em>and</em><br />
Regex <strong>G</strong>: <code>(?i)(?(DEFINE)(\bcity_n\b)((?:\W+\w+){0,50}\W+)(\bman_n\b))(?1)(?2)(?3)|(?3)(?2)(?1)</code></p>
<p dir="auto">Pass i.e. one match even after repeated search:</p>
<ol>
<li>Using RegexTester (by <a class="plugin-mentions-user plugin-mentions-a" href="/user/claudia-frank" aria-label="Profile: Claudia-Frank">@<bdi>Claudia-Frank</bdi></a>);</li>
<li>Using RegexBuddy w/ boost::regex 1.58-1.59 ECMAScript (default) flavor</li>
</ol>
<p dir="auto"><strong>FAIL</strong>:</p>
<ol>
<li>Find w/  wrap around - toggles between two matches on repeated search (partial and complete text);</li>
<li>Find w/o wrap around - “Can’t find text”</li>
</ol>
<hr />
<p dir="auto">Regex <strong>E</strong>: <code>(?i)(?(DEFINE)(\bcity_n\b)((?:\W+\w+){0,50}\W+)(\bman_n\b))(?&lt;=\W)(?1)(?2)(?3)(?=\W)|(?&lt;=\W)(?3)(?2)(?1)(?=\W)</code><br />
<em>and</em><br />
Regex <strong>F</strong>: <code>(?i)(?(DEFINE)(\bcity_n\b)((?:\W+\w+){0,50}\W+)(\bman_n\b))(?&lt;=\W)(?:(?1)(?2)(?3)|(?3)(?2)(?1))(?=\W)</code></p>
<p dir="auto">Pass i.e. one match even after repeated search:</p>
<ol>
<li>Using RegexTester (by <a class="plugin-mentions-user plugin-mentions-a" href="/user/claudia-frank" aria-label="Profile: Claudia-Frank">@<bdi>Claudia-Frank</bdi></a>);</li>
<li>Using RegexBuddy w/ boost::regex 1.58-1.59 ECMAScript (default) flavor</li>
</ol>
<p dir="auto"><strong>FAIL</strong>:</p>
<ol>
<li>Find w/  wrap around - toggles between two matches on repeated search (partial and complete text);</li>
<li>Find w/o wrap around - toggles between two matches on repeated search (complete text and “Can’t find text”)</li>
</ol>
<hr />
<p dir="auto">Regards,<br />
Menno</p>
]]></description><link>https://community.notepad-plus-plus.org/post/23265</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/23265</guid><dc:creator><![CDATA[MAPJe71]]></dc:creator><pubDate>Sun, 02 Apr 2017 11:07:56 GMT</pubDate></item><item><title><![CDATA[Reply to How to: Match Nested Pairs closed by END on Sun, 02 Apr 2017 09:54:46 GMT]]></title><description><![CDATA[<p dir="auto">Hi, <a class="plugin-mentions-user plugin-mentions-a" href="/user/mapje71" aria-label="Profile: mapje71">@<bdi>mapje71</bdi></a>,</p>
<p dir="auto">I, recently, noticed a <strong>difference</strong> between repeating a <strong>group #n</strong> and using its associated <strong>subroutine call</strong> <strong><code>(?n)</code></strong>, while using some regexes, in a <strong>.txt</strong> file, that <a class="plugin-mentions-user plugin-mentions-a" href="/user/iona-hine" aria-label="Profile: iona-hine">@<bdi>iona-hine</bdi></a> sent me, by e-mail, a couple of days, ago. Refer to this post, speaking of the <strong>general</strong> problem of finding a <strong>range</strong> of characters between <strong>two</strong> words ( Either the forms <strong><code>Word1......Word2</code></strong> OR <strong><code>Word2......Word1</code></strong> ! )</p>
<p dir="auto"><a href="https://notepad-plus-plus.org/community/topic/13513/proximity-search/6" rel="nofollow ugc">https://notepad-plus-plus.org/community/topic/13513/proximity-search/6</a></p>
<p dir="auto">The  <strong>Iona’s</strong> file, of size <strong>533,237</strong>, is an <strong>ONE-line UTF-8</strong> file, which contains <strong>532,875</strong> characters, from column <strong>1</strong> to column <strong>532,875</strong> !, organized in <strong>74115</strong> words. The characters are, mostly, <strong>word</strong> characters ( <strong>458,337</strong> ) + other symbols ( <strong>663</strong> ) and <strong>space</strong> characters ( <strong>73,875</strong> )</p>
<p dir="auto">In that file, <strong>Iona</strong> try to search for any range, between the <strong>initial</strong> boundary <strong><code>man_n</code></strong> and the <strong>final</strong> boundary <strong><code>city_n</code></strong>, or the <strong>opposite</strong>, with a <strong>maximum</strong> of <strong>50</strong> words between !. It’s interesting to note that this file contains <strong>467</strong> words <strong><code>man_n</code></strong> but <strong>ONLY ONE</strong> occurrence of the word <strong><code>city_n</code></strong>. Therefore, any regex looking for a <strong>range</strong> between these <strong>two</strong> words, should find only <strong>ONE occurrence</strong> !</p>
<p dir="auto">Using, for instance, the regexes <strong><code>A</code></strong> and <strong><code>B</code></strong>, below, we get, as expected, <strong>ONE</strong> match ( a range of <strong>167</strong> characters, beginning at column <strong>21,481</strong> ), in <strong>both</strong> cases.</p>
<p dir="auto">Regex <strong>A</strong> : <strong><code>(?si)(?&lt;=\W)(man_n)((?:\W+\w+){0,50}\W+)(city_n)(?=\W)|(?&lt;=\W)(?3)(?2)(?1)(?=\W)</code></strong></p>
<p dir="auto">Regex <strong>B</strong> : <strong><code>(?si)(?&lt;=\W)man_n(?:\W+\w+){0,50}\W+city_n(?=\W)|(?&lt;=\W)city_n(?:\W+\w+){0,50}\W+man_n(?=\W)</code></strong></p>
<hr />
<p dir="auto">Now, if we try the regex <strong><code>C</code></strong>, we get <strong>TWO</strong> matches ! ( The <strong>first</strong> one is <strong>correct</strong>, but the <strong>second</strong> match <strong>wrongly</strong> selects <strong>all</strong> the file contents ! )</p>
<p dir="auto">Regex <strong>C</strong> : <strong><code>(?si)(?&lt;=\W)(city_n)((?:\W+\w+){0,50}\W+)(man_n)(?=\W)|(?&lt;=\W)(?3)(?2)(?1)(?=\W)</code></strong></p>
<p dir="auto">However, if we use the <strong>equivalent</strong> regex <strong><code>D</code></strong>, below, without the <strong><code>(?#)</code></strong> syntaxes, it does match <strong>ONE</strong> match, only, without any <strong>bug</strong> !!</p>
<p dir="auto">Regex <strong>D</strong> : <strong><code>(?si)(?&lt;=\W)city_n(?:\W+\w+){0,50}\W+man_n(?=\W)|(?&lt;=\W)man_n(?:\W+\w+){0,50}\W+city_n(?=\W)</code></strong></p>
<p dir="auto">But, <a class="plugin-mentions-user plugin-mentions-a" href="/user/mapje71" aria-label="Profile: mapje71">@<bdi>mapje71</bdi></a>, this behaviour could occur because of my <strong>weak</strong> hardware configuration ( An old <strong>Win XP</strong> laptop, with <strong>1 Mo</strong> of memory ! )<br />
I just imagine your <strong>surprise</strong>, guys ! And you’re right, I, quickly, need a <strong>21th century</strong> machine ! But, on the other hand, working without any <strong>UAC</strong> feature and other goodies, of <strong>modern</strong> OS, is quite <strong>relaxing</strong>,  too :-))</p>
<p dir="auto">So, <a class="plugin-mentions-user plugin-mentions-a" href="/user/mapje71" aria-label="Profile: mapje71">@<bdi>mapje71</bdi></a>, I’m going to send you, that <strong>txt</strong> file, by <strong>e-mail</strong>, for further <strong>tests</strong>. And I hope that you’ll succeed to sort it out !</p>
<p dir="auto">Cheers,</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/23260</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/23260</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Sun, 02 Apr 2017 09:54:46 GMT</pubDate></item><item><title><![CDATA[Reply to How to: Match Nested Pairs closed by END on Sat, 01 Apr 2017 20:18:42 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> and <a class="plugin-mentions-user plugin-mentions-a" href="/user/per-isakson" aria-label="Profile: Per-Isakson">@<bdi>Per-Isakson</bdi></a>,</p>
<p dir="auto">Using a named capturing group for the keywords instead of a numbered group and use it as a subroutine probably wouldn’t make a difference i.e. leading to wrong results in big files …</p>
<pre><code class="language-XML">&lt;classRange
    mainExpr = "(?x)                    # free-spacing
                (?s)                    # dot matches new line
                (?-i)                   # case sensitive
                (?'KEYWORDS'            # --- open named capturing group
                    \b                  # word boundary
                    (?:                 # open non-capturing group with keywords that open a Balanced Construct that is closed by 'end'.
                        classdef
                    |   e(?:numeration|vents)
                    |   f(?:or|unction)
                    |   if
                    |   methods
                    |   p(?:arfor|roperties)
                    |   switch
                    |   try
                    |   while
                    )
                    \b                  # word boundary
                )                       # --- close named capturing group
                (?:                     # open non-capturing group
                    (?:                 # open non-capturing group
                        (?!             # negative look-ahead
                            (?&amp;amp;KEYWORDS)
                        |   \bend\b
                        )               # if not a keyword
                        .               # then one character
                    )+                  # repeat until keyword found
                |   (?0)                # recurse RE from start
                )+                      # repeat
                \bend\b
                "
</code></pre>
<p dir="auto">And subroutine definition(s)?<br />
e.g.</p>
<pre><code class="language-XML">&lt;classRange
    mainExpr = "(?x)                            # free-spacing
                (?s)                            # dot matches new line
                (?-i)                           # case sensitive
                (?(DEFINE)                      # Define subroutines
                    (?'OPEN_KEYWORDS'
                        \b                      # word boundary
                        (?:                     # open non-capturing group with keywords that open a Balanced Construct that is closed by 'end'.
                            classdef
                        |   e(?:numeration|vents)
                        |   f(?:or|unction)
                        |   if
                        |   methods
                        |   p(?:arfor|roperties)
                        |   switch
                        |   try
                        |   while
                        )
                        \b                      # word boundary
                    )
                    (?'CLOSE_KEYWORDS'
                        \b                      # word boundary
                        end
                        \b                      # word boundary
                    )
                )
                (?&amp;amp;OPEN_KEYWORDS)               # call subroutine
                (?:                             # open non-capturing group
                    (?:                         # open non-capturing group
                        (?!                     # negative look-ahead
                            (?&amp;amp;OPEN_KEYWORDS)   # call subroutine
                        |   (?&amp;amp;CLOSE_KEYWORDS)  # call subroutine
                        )                       # if not a keyword
                        .                       # then one character
                    )+                          # repeat until keyword found
                |   (?0)                        # recurse RE from start
                )+                              # repeat
                (?&amp;amp;CLOSE_KEYWORDS)              # call subroutine
                "
</code></pre>
]]></description><link>https://community.notepad-plus-plus.org/post/23256</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/23256</guid><dc:creator><![CDATA[MAPJe71]]></dc:creator><pubDate>Sat, 01 Apr 2017 20:18:42 GMT</pubDate></item><item><title><![CDATA[Reply to How to: Match Nested Pairs closed by END on Sat, 01 Apr 2017 14:24:06 GMT]]></title><description><![CDATA[<p dir="auto">Hi, <a class="plugin-mentions-user plugin-mentions-a" href="/user/per-isakson" aria-label="Profile: per-isakson">@<bdi>per-isakson</bdi></a> and <strong>All</strong>,</p>
<p dir="auto">Sorry, but I was quite <strong>busy</strong> to answer a ( <strong>long</strong> ! ) e-mail to <a class="plugin-mentions-user plugin-mentions-a" href="/user/iona-hine" aria-label="Profile: iona-hine">@<bdi>iona-hine</bdi></a>.</p>
<p dir="auto"><a href="https://notepad-plus-plus.org/community/topic/13513/proximity-search/11" rel="nofollow ugc">https://notepad-plus-plus.org/community/topic/13513/proximity-search/11</a></p>
<p dir="auto">And, while testing some regexes, for him, I just noticed that the <strong>interesting</strong> syntaxes <strong><code>(?#)</code></strong>, that represents a subroutine to the group <strong>#</strong>, itself, may, in some cases, especially in <strong>big</strong> files, lead to <strong>wrong</strong> results, as, for instance, to the <strong>all contents</strong> wrong match !</p>
<p dir="auto">So, referring to my <strong>previous</strong> regex :</p>
<p dir="auto"><strong><code>(?s-i)(if|for|while|switch|try|parfor)((?:(?!(?1)|end).)+|(?R))+end</code></strong></p>
<p dir="auto">It would be better, finally, to rewrite it as :</p>
<p dir="auto"><strong><code>(?s-i)(if|for|while|switch|try|parfor)((?:(?!if|for|while|switch|try|parfor|end).)+|(?R))+end</code></strong></p>
<hr />
<p dir="auto">Therefore, <a class="plugin-mentions-user plugin-mentions-a" href="/user/per-isakson" aria-label="Profile: per-isakson">@<bdi>per-isakson</bdi></a>, may be, it would be better to <strong>change</strong>, in your regex, the part :</p>
<pre><code class="language-jsp">                        (?1)|\bend\b
</code></pre>
<p dir="auto">By the following :</p>
<pre><code class="language-jsp">                            \b                  # word boundary  
                            (                   # --- open 4th group
                                classdef        # keywords, of the 2nd group + 'end',
                                |properties     # which must NOT occur,
                                |events         # at ANY position, of the
                                |enumaration    # present sub-block, till
                                |methods        # its associated 'end' closing word
                                |function
                                |if
                                |for
                                |while
                                |switch
                                |try
                                |parfor
                                |end
                            )                   # --- close 4th group
                            \b                  # word boundary 

</code></pre>
<p dir="auto">BTW, you succeed, to include <strong>word</strong> boundaries in your regex ! Fine :-) Cant remember while I found out some <strong>problems</strong>, while trying to do the same thing !</p>
<p dir="auto">Oh ! May be that, instead of the keyword <strong><code>enumaration</code></strong>, you would mean <strong><code>enumeration</code></strong> !</p>
<hr />
<p dir="auto"><strong>REMARK</strong> :</p>
<p dir="auto">On my <strong>small</strong> example test, I tested the <strong>new</strong> syntax of my <strong>previous</strong> regex, but it does produce, too, the <strong>all contents</strong> bug :-((. So, I suppose that it’s rather related to the <strong>recursion</strong> handling by the present <strong>N++ Boost</strong> regex engine ?!</p>
<p dir="auto">Cheers,</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/23252</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/23252</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Sat, 01 Apr 2017 14:24:06 GMT</pubDate></item><item><title><![CDATA[Reply to How to: Match Nested Pairs closed by END on Sat, 01 Apr 2017 02:52:51 GMT]]></title><description><![CDATA[<p dir="auto">Hello <a class="plugin-mentions-user plugin-mentions-a" href="/user/guy038" aria-label="Profile: guy038">@<bdi>guy038</bdi></a></p>
<p dir="auto">Thank you for the recursive  regular expression. I have modified it a bit and included into my functionList.xml.</p>
<p dir="auto">The expression works with TextFX, Quick, FindReplace and <a href="https://regex101.com/" rel="nofollow ugc">https://regex101.com/</a>.  (<code>classdef</code> must be the first keyword in the file, but that’s okay.)</p>
<p dir="auto">The expression is costly to execute (some seconds on my old PC) and regex101 says <code>Catastrofic Backtracking</code> to many of my test-files. I failed to significantly improve the performance.</p>
<p dir="auto">However, embedded in functionList.xml it’s not a total success. Some test-files, which TextFX|Quick|FindReplace handles well, only produces the filename in the Function List pane. I will report on that in the thread  <code>Trouble making a functionList parser for MATLAB</code>, #13505.</p>
<p dir="auto">Best Regards<br />
per isakson</p>
<pre><code>&lt;classRange
    mainExpr = "(?x)(?s)                # dot matches new line
                (?-i)                   # case sensitive
                (                       # --- open 1st group 
                    \b                  # word boundary  
                    (                   # --- open 2nd group
                        classdef        # keywords that open a  
                        |properties     # Balanced Construct
                        |events         # that is closed by 
                        |enumaration    # 'end'.
                        |methods            
                        |function
                        |if
                        |for
                        |while
                        |switch
                        |try
                        |parfor
                    )                   # --- close 2nd group
                    \b                  # word boundary 
                )                       # --- close 1st group
                
                (                       # open 3rd capturing group    
                    (?:                 # open non-capturing group
                        (?!             # negative look-ahead
                        (?1)|\bend\b    # if not a keyword
                        ).              # then one character
                    )+                  # repeat 
                    |                   # until keyword found
                    (?0)                # recurse RE from start
                )+                      # repeat 3rd group
                \bend\b                 #      
                "</code></pre>
]]></description><link>https://community.notepad-plus-plus.org/post/23245</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/23245</guid><dc:creator><![CDATA[Per Isakson]]></dc:creator><pubDate>Sat, 01 Apr 2017 02:52:51 GMT</pubDate></item><item><title><![CDATA[Reply to How to: Match Nested Pairs closed by END on Wed, 29 Mar 2017 19:15:29 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> FYI it’s related to <a href="https://notepad-plus-plus.org/community/topic/13505/trouble-making-a-functionlist-parser-for-matlab" rel="nofollow ugc">#13505</a>.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/23168</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/23168</guid><dc:creator><![CDATA[MAPJe71]]></dc:creator><pubDate>Wed, 29 Mar 2017 19:15:29 GMT</pubDate></item><item><title><![CDATA[Reply to How to: Match Nested Pairs closed by END on Tue, 28 Mar 2017 23:17:21 GMT]]></title><description><![CDATA[<p dir="auto">Hello, <a class="plugin-mentions-user plugin-mentions-a" href="/user/per-isakson" aria-label="Profile: per-isakson">@<bdi>per-isakson</bdi></a>,</p>
<p dir="auto">My <strong>first</strong> attempt, with the <strong>initial-key</strong> words <strong><code>if</code></strong>, <strong><code>for</code></strong>, <strong><code>while</code></strong>, <strong><code>switch</code></strong>, <strong><code>try</code></strong>, <strong><code>parfor</code></strong> and the <strong>final-key</strong> word <strong><code>end</code></strong>, all in <strong>lower-case</strong>, would be the regex, below :</p>
<p dir="auto"><strong><code>(?s-i)(if|for|while|switch|try|parfor)((?:(?!(?1)|end).)+|(?R))+end</code></strong></p>
<p dir="auto">Just try it against the <strong>sample</strong> text :</p>
<pre><code class="language-css">
if

  while

  end

end

forend  ( Test : normally NOT matched )

if

end

end


for if end while for if end end end for if end end end end end

for  if  end  while  for  if  end  end  end  for  if  end  end  end  end  end  end  end


for
  if
  end
   while
    for
      if
      end
    end
  end
  for
    if
    end
  end
end
end
end
end
</code></pre>
<p dir="auto">You should obtain <strong>five</strong> occurrences, capturing <strong>2 single-line</strong> zones and <strong>3 multi-lines</strong> blocks</p>
<hr />
<p dir="auto">Of course, as this regex just search for the <strong>exact</strong> words, without <strong>word boundaries</strong>, it wouldn’t mind, for instance, about the <strong>wrong</strong> block, below, selecting from the letters <strong>for</strong> to the letters <strong>end</strong></p>
<pre><code class="language-css">afor
....
....
....
endz
</code></pre>
<p dir="auto">I tried to build a <strong>more complete</strong> regex, with <strong>word</strong> boundaries, as <strong><code>\W</code></strong>, and the look-arounds <strong><code>(?&lt;=\W)</code></strong> and <strong><code>(?=\W)</code></strong>, but my solutions led to other <strong>problems</strong> and didn’t match <strong>all</strong> the cases, anyway ! Then, I realized that it would be better, finally, to <strong>detect</strong>, FIRST, in your code, any <strong>key-word</strong>, used in that regex, when <strong>“glued”</strong> to other letters, in a <strong>bigger</strong> word ! To that purpose, use the regex( again ! ), below :</p>
<p dir="auto"><strong><code>\w(if|(?&lt;!par)for|while|switch|try|parfor|end)|(?1)\w</code></strong></p>
<p dir="auto"><strong>IMPORTANT</strong> : Sometimes, when clicking, ONE MORE time, on the <strong>Find Next</strong> button, <strong>all</strong> the file contents are <strong>wrongly selected</strong>. It’s a <strong>well-known</strong> bug, which occurs, while using, mostly, <strong>recursive regular</strong> expressions :-(( I can’t explain that behaviour ! May be, my regex is <strong>not</strong> well-formed !?</p>
<p dir="auto">Best Regards,</p>
<p dir="auto">guy038</p>
<p dir="auto"><strong>P.S.</strong> :</p>
<p dir="auto">If this regex put you on the <strong>right</strong> direction, I give you, <strong>next</strong> time, some <strong>details</strong> on what it means !!</p>
]]></description><link>https://community.notepad-plus-plus.org/post/23151</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/23151</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Tue, 28 Mar 2017 23:17:21 GMT</pubDate></item></channel></rss>