<?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[Select all exclamation marks ! from a specific html tag]]></title><description><![CDATA[<p dir="auto"><code>&lt;p class="ONE"&gt;LoveThePlanet products are free from ! parabens and palm oil, despatched in paper envelopes !as well&lt;/p&gt;</code></p>
<p dir="auto"><code>&lt;p class="TWO"&gt;LoveThePlanet products are free from ! parabens and palm oil, despatched in paper envelopes !as well&lt;/p&gt;</code></p>
<p dir="auto">So, I want to select all exclamation marks <code>!</code> from the tag <code>&lt;p class="ONE"&gt;...&lt;/p&gt;</code> and to replace it with a space before and after it</p>
<p dir="auto">I made a regex, but it select also the second tag, but I want to modify only the first one (<code>&lt;p class="ONE"&gt;</code>)</p>
<p dir="auto">FIND: <code>(?:&lt;p class="one"&gt;|\G)[^|"]*\K \!\h|\!\h*</code></p>
<p dir="auto">REPLACE BY: <code>\x20!\x20</code></p>
<p dir="auto">So, the single problem is that my regex will modify also the second html tag <code>&lt;p class="TWO"&gt;</code>, and I want to modify only the first html tag <code>&lt;p class="ONE"&gt;</code></p>
]]></description><link>https://community.notepad-plus-plus.org/topic/20579/select-all-exclamation-marks-from-a-specific-html-tag</link><generator>RSS for Node</generator><lastBuildDate>Wed, 15 Apr 2026 04:34:47 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/20579.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 09 Jan 2021 12:35:32 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Select all exclamation marks ! from a specific html tag on Tue, 02 Feb 2021 19:33:36 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/195">@guy038</a> said in <a href="/post/62131">Select all exclamation marks ! from a specific html tag</a>:</p>
<blockquote>
<p dir="auto">So the generic regexes, of my previous post, should be improved as :<br />
SEARCH (?s)(?:BR|(?!\A)\G)(?:(?!ER).)<em>?\K(?:SR)    OR    (?-s)(?:BR|(?!\A)\G)(?:(?!ER).)</em>?\K(?:SR)</p>
</blockquote>
<p dir="auto">So, Guy, just a note again to say thanks for this.<br />
I have employed it 3 or 4 times in the last week, and I anticipate much more usage in the future.<br />
Very handy!</p>
<p dir="auto">One good example is in a section of a log file I have to process repeatedly.<br />
The section starts with certain line contents and ends with certain other line contents (thus <strong>BR</strong> and <strong>ER</strong>).<br />
Inside this section there are subsection headers (that have a consistent pattern to their format), and also “WARNING”, “ERROR”, “FAILED” , etc. text that follow the subsection headers (identifying problems within that subsection).<br />
By combining the headers and the error text bits in an OR’d together regex (to form the <strong>SR</strong>),I can create some nice output (in the <em>Search result</em> window) that identifies clearly the subsections that have “problems” and those that are “clean”.</p>
<p dir="auto">So very nice.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/62436</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/62436</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Tue, 02 Feb 2021 19:33:36 GMT</pubDate></item><item><title><![CDATA[Reply to Select all exclamation marks ! from a specific html tag on Sun, 24 Jan 2021 19:19:36 GMT]]></title><description><![CDATA[<p dir="auto">Hello, <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/7377">@alan-kilborn</a> and <strong>All</strong>,</p>
<p dir="auto">Unfortunately, we should have <strong>predicted</strong> such behavior !</p>
<p dir="auto">Basically, your regex <strong><code>(?s)(foo\(|\G)((?!\);).)*?\K0x(BA|DE)</code></strong> looks, <strong>either</strong> :</p>
<ul>
<li>
<p dir="auto">For the literal string <strong><code>foo(</code></strong>, followed by <strong>any</strong> char till the <strong>first</strong> literal string <strong><code>0xBA</code></strong> or <strong><code>0xDE</code></strong></p>
</li>
<li>
<p dir="auto">For <strong>any</strong> char , <strong>right after</strong> the <strong>previous</strong> match ( <strong><code>\G</code></strong> ) till the <strong>first</strong> literal string <strong><code>0xBA</code></strong> or <strong><code>0xDE</code></strong></p>
</li>
</ul>
<p dir="auto">So, given this <strong>sample</strong> :</p>
<pre><code class="language-z">0xBA    ( Line A )
0xBA

0xDE

int x = foo(0,

0xBA

0xDE

);

    ( Line B )

0xDE

0xBA

int x = foo(0,

0xDE

0xBA

);

0xBA

0xDE


0xBA

0xDE

int x = foo(0,

0xBA

0xDE

);

0xBA

0xDE
</code></pre>
<p dir="auto">Move the caret to the <strong>very beginning</strong> of line <strong><code>B</code></strong>, for instance. Normally, as the next <strong><code>0xDE</code></strong> is still <strong>outside</strong> a function <strong><code>f00</code></strong> range, it should <strong>not</strong> be matched. However, it <strong>does</strong> match this occurrence ! Why ?</p>
<p dir="auto">Because of the <strong>combination</strong> of the <strong><code>(?s)</code></strong> modifier, which considers <strong>any</strong> char and the <strong><code>\G</code></strong> assertion : wherever your <strong>caret</strong> is located, the <strong><code>\G</code></strong> assertion is always <strong>true</strong> when your <strong>first</strong> execute your regex . Indeed, in this case, the regex engine considers that a <strong>virtual</strong> previous occurrence occurred and stopped <strong>right before</strong> the caret location. So, it will <strong>always</strong> find the <strong>nearest</strong> literal string <strong><code>0xBA</code></strong> or <strong><code>0xDE</code></strong>, at any location ( refer to the regex <strong><code>(?s)\G.*?0x(BA|DE)</code></strong> )</p>
<hr />
<p dir="auto">Luckily, I found out a solution, which supposes that <strong>three</strong> hypotheses are <strong>verified</strong> :</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>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>
<li>
<p dir="auto">You must use the <strong><code>(?!\A)\G</code></strong> syntax, in the <strong>overall</strong> regex ( instead of <strong><code>\G</code></strong> ! )</p>
</li>
</ul>
<hr />
<p dir="auto">So the <strong>generic</strong> regexes, of my <strong>previous</strong> post, should be <strong>improved</strong> as :</p>
<p dir="auto">SEARCH <strong><code>(?s)(?:</code>BR<code>|(?!\A)\G)(?:(?!</code>ER<code>).)*?\K(?:</code>SR<code>)</code></strong>    OR    <strong><code>(?-s)(?:</code>BR<code>|(?!\A)\G)(?:(?!</code>ER<code>).)*?\K(?:</code>SR<code>)</code></strong></p>
<p dir="auto">And gives, for your <strong>specific</strong> regex :</p>
<pre><code class="language-z">(?xs)  (?: foo\( | (?! \A ) \G )  (?: (?! \); ). )*?  \K  (?: 0x(BA|DE) )
</code></pre>
<p dir="auto">You may verify, with the provided <strong>sample</strong>, that, at soon as the caret is <strong>not</strong> at the <strong>very beginning</strong> of the <strong>first</strong> line ( Line <strong><code>A</code></strong> ), before running this <strong>improved</strong> regex, it <strong>wrongly</strong> matches the two strings <strong><code>0xBA</code></strong> and the string <strong><code>0xDE</code></strong>, located before the <strong>first</strong> <strong><code>foo\(</code></strong> string !</p>
<p dir="auto">Hence, the necessity to respect the <strong>second</strong> hypothesis above, which ensures that the <strong><code>\A</code></strong> assertion is <strong>true</strong>, before regex execution. By this means, the <strong>second</strong> alternative of <strong>BR</strong> : <strong><code>(?!\A)\G</code></strong> will <strong>not</strong> be <strong>true</strong>, at the <strong>first</strong> execution of the regex  ;-)</p>
<p dir="auto">BR</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/62131</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/62131</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Sun, 24 Jan 2021 19:19:36 GMT</pubDate></item><item><title><![CDATA[Reply to Select all exclamation marks ! from a specific html tag on Sun, 24 Jan 2021 00:28:43 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/195">@guy038</a> said in <a href="/post/62121">Select all exclamation marks ! from a specific html tag</a>:</p>
<blockquote>
<p dir="auto"><code>(?s)(foo\(|\G)((?!\);).)*?\K0x(BA|DE)</code>    : Your regex</p>
</blockquote>
<p dir="auto">I seem to have found a problem; with this text:</p>
<pre><code class="language-z">int y = 0xBA;

int z = 0xDE;

int x = foo(0,
    12,
    34,
    0xDE,
    12,
    0xBA,
    34,
    27);  // this is another way I could write my foo function
</code></pre>
<p dir="auto">I get hits on the <code>y =</code> and <code>z =</code> lines, even though I thought they had to be inside the <code>foo(</code> and <code>);</code> delimiters for there to be such hits…</p>
]]></description><link>https://community.notepad-plus-plus.org/post/62129</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/62129</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Sun, 24 Jan 2021 00:28:43 GMT</pubDate></item><item><title><![CDATA[Reply to Select all exclamation marks ! from a specific html tag on Sat, 23 Jan 2021 18:02:23 GMT]]></title><description><![CDATA[<p dir="auto">Hi, <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/7377">@alan-kilborn</a>,</p>
<p dir="auto"><strong>Nice</strong> deductions, indeed ! You’re right in <strong>many</strong> ways : using <strong>non-capturing</strong> groups, everywhere, should be <strong>beneficial</strong> in all cases .  :</p>
<ul>
<li>
<p dir="auto">Firstly, using the <strong>non-capturing</strong> group <strong><code>(?:(?!</code>ER<code>).)</code></strong> prevents the regex engine from storing any <strong>single</strong> character between the <strong>BR</strong>/<strong>current</strong> location and the <strong>SR</strong>, one at a time, which should increase the <strong>global</strong> performance of the <strong>overall</strong> regex ( as some <strong>code</strong> simplification in a <strong>loop</strong> ! )</p>
</li>
<li>
<p dir="auto">Secondly, using the <strong>non-capturing</strong> group <strong><code>(?:</code>SR<code>)</code></strong> can be interesting if you should <strong>re</strong>-use a part of the <strong>SR</strong>, in the <strong>replacement</strong> part and ensures you that you just have to start with <strong>group <code>1</code></strong> !</p>
</li>
<li>
<p dir="auto">Now, I think that the <strong>first</strong> part <strong><code>((?:</code>BR<code>)|\G)</code></strong> could simply be expressed as <strong><code>(?:</code>BR<code>|\G)</code></strong>, because the <strong>zero-length</strong> assertion <strong><code>\G</code></strong> is not going to be <strong>stored</strong>, anyway ;-))</p>
</li>
</ul>
<hr />
<p dir="auto">Finally, we end with these <strong>generic</strong> expressions :</p>
<p dir="auto">SEARCH <strong><code>(?s)(?:</code>BR<code>|\G)(?:(?!</code>ER<code>).)*?\K(?:</code>SR<code>)</code></strong>    OR    <strong><code>(?-s)(?:</code>BR<code>|\G)(?:(?!</code>ER<code>).)*?\K(?:</code>SR<code>)</code></strong></p>
<p dir="auto">REPLACE <strong>RR</strong></p>
<p dir="auto">where :</p>
<ul>
<li>
<p dir="auto"><strong>BR</strong> ( <strong>B</strong>egining <strong>R</strong>egex ) is the regex which defines the <strong>start</strong> of the <strong>specific</strong> area to look for a <strong>possible</strong> <strong>S</strong>earch <strong>R</strong>egex match</p>
</li>
<li>
<p dir="auto"><strong>ER</strong> ( <strong>E</strong>xcluded <strong>R</strong>egex ) is the regex which defines the <strong>characters</strong> and/or <strong>strings</strong> <strong><code>forbidden</code></strong>, from the <strong>B</strong>egining <strong>R</strong>egex position until a next <strong>S</strong>earch <strong>R</strong>egex match. It, implicitly, defines areas of <strong>continuous</strong> characters, where the <strong>S</strong>earch <strong>R</strong>egex must occur and <strong>not</strong> elsewhere !</p>
</li>
<li>
<p dir="auto"><strong>SR</strong> ( <strong>S</strong>earch <strong>R</strong>egex ) is the regex which defines the expression to <strong>search</strong> for, if , both, the <strong>B</strong>egining <strong>R</strong>egex has been matched and the <strong>E</strong>xcluded <strong>R</strong>egex has <strong>not</strong> been matched so far, at <strong>any</strong> position, between <strong>BR</strong> and <strong>SR</strong></p>
</li>
<li>
<p dir="auto"><strong>RR</strong>  ( <strong>R</strong>eplace <strong>R</strong>egex ) is simply the regex which defines the <strong>regex</strong> expression <strong>replacing</strong> the <strong>S</strong>earch <strong>R</strong>egex</p>
</li>
</ul>
<p dir="auto">Note, that I rewrote the <strong>last</strong> part of the the <strong>ER</strong> and <strong>SR</strong> definitions !</p>
<p dir="auto">And, if this <strong>ER</strong> zone is <strong>not</strong> needed, these <strong>generic</strong> regexes can be simplified as :</p>
<p dir="auto">SEARCH <strong><code>(?s)(?:</code>BR<code>|\G).*?\K(?:</code>SR<code>)</code></strong>    OR    <strong><code>(?-s)(?:</code>BR<code>|\G).*?\K(?:</code>SR<code>)</code></strong></p>
<p dir="auto"><strong>IMPORTANT</strong> : Because the <strong>ER</strong> regex implicitly defines several <strong>non-contiguous</strong> areas where <strong>SR</strong> may exist, when the regex engine <strong>skip</strong> from a zone ( the <strong>yellow</strong> area of my <strong>previous</strong> post ) to the next <strong>non-contiguous</strong> zone ( The <strong>blue</strong> area, after the ending parenthesis ), the <strong><code>\G</code></strong> is <strong>not</strong> verified anymore and only the <strong>first</strong> alternative <strong>BR</strong> must occur first to get, <strong>later</strong>, a possible match of <strong>SR</strong></p>
<hr />
<p dir="auto">So, your <strong>previous</strong> regex could be written as :</p>
<p dir="auto">SEARCH <strong><code>(?s)(?:foo\(|\G)(?:(?!\);).)*?\K(?:0x(BA|DE))</code></strong></p>
<p dir="auto">And using the <strong>free-spacing</strong> mode <strong><code>(?x)</code></strong>, it becomes :</p>
<pre><code class="language-z">
(?xs)  (?: foo\( | \G )  (?: (?! \); ). )*?  \K  (?: 0x(BA|DE) )        TESTED =&gt; OK
           ¯¯¯¯¯                 ¯¯¯                 ¯¯¯¯¯¯¯¯¯
            BR                   ER                     SR
</code></pre>
<p dir="auto">Best Regards,</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/62123</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/62123</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Sat, 23 Jan 2021 18:02:23 GMT</pubDate></item><item><title><![CDATA[Reply to Select all exclamation marks ! from a specific html tag on Sat, 23 Jan 2021 15:18:40 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/195">@guy038</a></p>
<p dir="auto">Yes, that clarifies things; thank you for that.</p>
<hr />
<p dir="auto">Onto a new aspect…</p>
<p dir="auto">Again, here’s your original general case regex:</p>
<p dir="auto"><code>(?-s)(</code><strong>BR</strong><code>|\G)((?!</code><strong>ER</strong><code>).)*?\K</code><strong>SR</strong></p>
<p dir="auto">Would it be better to express it this way?:</p>
<p dir="auto"><code>(?-s)((?:</code><strong>BR</strong><code>)|\G)((?!</code><strong>ER</strong><code>).)*?\K(?:</code><strong>SR</strong><code>)</code></p>
<p dir="auto">So that the BR and SR expressions “stay together” if they are “complicated”?  Or are they already totally “safe” the way you expressed them in the original?  I’m not totally sure of the precedence of the <code>|</code> operator, and especially not the <code>\K</code> – is the <code>\K</code> of “top priority”?</p>
<p dir="auto">The ER already seems sufficiently “wrapped” via <code>(?!</code>…<code>)</code> and shouldn’t need any more than that, although the <em>outer</em> grouping on <code>ER</code> seems as if it could be non-capturing as well, so maybe:</p>
<p dir="auto"><code>(?-s)((?:</code><strong>BR</strong><code>)|\G)(?:(?!</code><strong>ER</strong><code>).)*?\K(?:</code><strong>SR</strong><code>)</code></p>
<p dir="auto">I’m not trying to take this totally off-topic into regex land, but I intend to use this technique with N++ a lot in the future, so (to me) it is worth exploring fully.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/62122</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/62122</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Sat, 23 Jan 2021 15:18:40 GMT</pubDate></item><item><title><![CDATA[Reply to Select all exclamation marks ! from a specific html tag on Sat, 23 Jan 2021 13:57:24 GMT]]></title><description><![CDATA[<p dir="auto">Hi, <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/7377">@alan-kilborn</a>,</p>
<p dir="auto">I thought it was better to write this post with <strong>Word</strong> and provide a <strong>screenshot</strong>, in order to see <strong>colored</strong> zones and some writing <strong>styles</strong> ;-))</p>
<p dir="auto">The <strong>sample</strong> text used is :</p>
<pre><code class="language-z">x = foo(0, 
    12, 
    34, 
    0xDE, 
    12, 
    0xBA, 
    34, 
    27);  // this is another way I could write my foo function

0xDE
This is

0xBA
a test

x = foo(0, 
    12, 
    34, 
    0xDE, 
    12, 
    0xBA, 
    34, 
    27);  // this is another way I could write my foo function

0xDE
This is

0xBA
a test
</code></pre>
<p dir="auto"><img src="/assets/uploads/files/1611409366323-a9772e5c-7f7a-440b-936f-96c4ebe588d9-image.png" alt="a9772e5c-7f7a-440b-936f-96c4ebe588d9-image.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">Best Regards,</p>
<p dir="auto">guy038</p>
<p dir="auto"><strong>Alan</strong>, as it could be difficult to <strong>rewrite</strong> all the regexes for tests, here they are, in their <strong>order</strong> of appearance :</p>
<ul>
<li>
<p dir="auto"><strong><code>(?s)(?!\);).</code></strong></p>
</li>
<li>
<p dir="auto"><strong><code>(?s)(foo\(|\G)((?!\);).)*?\K0x(BA|DE)</code></strong>    : <strong>Your</strong> regex</p>
</li>
<li>
<p dir="auto"><strong><code>(?s)(foo\(|\G)((?!\);).)*?\K0x(BA|DE)(?=((?!\);).)*?\);)</code></strong></p>
</li>
<li>
<p dir="auto"><strong><code>(?s)(foo\(|\G).*?\K0x(BA|DE)</code></strong></p>
</li>
<li>
<p dir="auto"><strong><code>(?s)(foo\(|\G).*?\K0x(BA|DE)(?=.*?\);)</code></strong></p>
</li>
</ul>
<p dir="auto">Oh, I just saw the <strong>caret</strong> of my <strong>Word</strong> document, located inside the <strong>first</strong> <strong><code>(?s)(?!\);).</code></strong> regex ! Don’t pay any attention ;-))</p>
]]></description><link>https://community.notepad-plus-plus.org/post/62121</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/62121</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Sat, 23 Jan 2021 13:57:24 GMT</pubDate></item><item><title><![CDATA[Reply to Select all exclamation marks ! from a specific html tag on Fri, 22 Jan 2021 22:07:02 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/195">@guy038</a> said:</p>
<blockquote>
<p dir="auto">ER ( Excluded Regex ) is the regex which defines the characters and/or strings forbidden, from the Begining Regex position until a next Search Regex match. It, implicitly, defines a zone, where the Search Regex may occur and not elsewhere !</p>
</blockquote>
<p dir="auto">I was trying to use this, but I’m sort of confused about the “ER”, and perhaps it is just trying to decode the sentence above.</p>
<p dir="auto">What I was needing to do is find, inside a function <code>foo</code> for a function parameter of, literally, <code>0xBA</code> or <code>0xDE</code>.  Thus, I want to match:</p>
<pre><code class="language-z">x = foo(0, 12, 0xBA, 34, 27);  // this is my foo function
</code></pre>
<p dir="auto">But <code>foo</code> could also be spread across several lines:</p>
<pre><code class="language-z">x = foo(0, 
    12, 
    34, 
    0xDE, 
    27);  // this is another way I could write my foo function
</code></pre>
<p dir="auto">So I set up the technique this way:</p>
<p dir="auto">BR = <code>foo\(</code><br />
ER = <code>\);</code><br />
SR = <code>0x(BA|DE)</code></p>
<p dir="auto">to get a final search regex of <code>(?s)(foo\(|\G)((?!\);).)*?\K0x(BA|DE)</code></p>
<p dir="auto">It <em>seemed</em> to work, but I really was unsure about my “ER” expression, so <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/195">@guy038</a> , if you could comment and shed some additional light on it for me, I’d appreciate it.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/62119</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/62119</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Fri, 22 Jan 2021 22:07:02 GMT</pubDate></item><item><title><![CDATA[Reply to Select all exclamation marks ! from a specific html tag on Sun, 10 Jan 2021 12:34:24 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/195">@guy038</a></p>
<p dir="auto">I as well like your explanation.<br />
It could help people start learning how to solve these types of problems.<br />
Perhaps in the future posters (and especially repetitive posters asking the same questions for similar situations) could be directed to this solution to try before asking for more help.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/61602</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/61602</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Sun, 10 Jan 2021 12:34:24 GMT</pubDate></item><item><title><![CDATA[Reply to Select all exclamation marks ! from a specific html tag on Sun, 10 Jan 2021 12:09:20 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/195">@guy038</a> very well explained, thank you</p>
]]></description><link>https://community.notepad-plus-plus.org/post/61600</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/61600</guid><dc:creator><![CDATA[Robin Cruise]]></dc:creator><pubDate>Sun, 10 Jan 2021 12:09:20 GMT</pubDate></item><item><title><![CDATA[Reply to Select all exclamation marks ! from a specific html tag on Sat, 23 Jan 2021 21:40:40 GMT]]></title><description><![CDATA[<p dir="auto">Hello, <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/7377">@alan-kilborn</a>, <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/7753">@robin-cruise</a> and All,</p>
<p dir="auto">See the <strong>updated</strong> version of this post, with the <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/7377">@alan-kilborn</a> advices at    <a href="https://community.notepad-plus-plus.org/post/62123">https://community.notepad-plus-plus.org/post/62123</a></p>
<hr />
<p dir="auto"><strong>Alan</strong>, you <strong>quite right</strong> about it. For instance, the <strong>three</strong> main search regexes that I provided to <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/7753">@robin-cruise</a>, expressed with the <strong>free-spacing</strong> mode, are, finally  :</p>
<pre><code class="language-z">Regex A   (?xs)    (?:  &lt;My\ Tag&gt;         |  \G  )    ((?!^&lt;).)+?    &lt;a\ href="    \K               (?=/)

Regex B   (?xs)    (?:  &lt;!--\ BEGIN\ --&gt;  |  \G  )    ((?!^&lt;).)+?    &lt;a\ href="    \K               (?=/)

Regex C   (?xi-s)  (?:  &lt;p\ class="ONE"&gt;  |  \G  )        .*?                      \K    \h*!\h*
</code></pre>
<p dir="auto">They follow the <strong>generic</strong> scheme, below :</p>
<p dir="auto">SEARCH <strong><code>(?-s)(</code>BR<code>|\G)((?!</code>ER<code>).)*?\K</code>SR</strong>        OR        <strong><code>(?s)(</code>BR<code>|\G)((?!</code>ER<code>).)*?\K</code>SR</strong></p>
<p dir="auto">REPLACE <strong>RR</strong></p>
<p dir="auto">where :</p>
<ul>
<li>
<p dir="auto"><strong>BR</strong> ( <strong>B</strong>egining <strong>R</strong>egex ) is the regex which defines the <strong>start</strong> of the <strong>specific</strong> area to look for a <strong>possible</strong> <strong>S</strong>earch <strong>R</strong>egex match</p>
</li>
<li>
<p dir="auto"><strong>ER</strong> ( <strong>E</strong>xcluded <strong>R</strong>egex ) is the regex which defines the <strong>characters</strong> and/or <strong>strings</strong> <strong><code>forbidden</code></strong>, from the <strong>B</strong>egining <strong>R</strong>egex position until a next <strong>S</strong>earch <strong>R</strong>egex match. It, implicitly, defines a <strong>zone</strong>, where the <strong>S</strong>earch <strong>R</strong>egex may occur and <strong>not</strong> elsewhere !</p>
</li>
<li>
<p dir="auto"><strong>SR</strong> ( <strong>S</strong>earch <strong>R</strong>egex ) is the regex which defines the expression to <strong>search</strong> for, if , both, the <strong>B</strong>egining <strong>R</strong>egex has been matched and the <strong>E</strong>xcluded <strong>R</strong>egex has <strong>not</strong> been matched so far, at <strong>any</strong> position</p>
</li>
<li>
<p dir="auto"><strong>RR</strong>  ( <strong>R</strong>eplace <strong>R</strong>egex ) is simply the regex which defines the <strong>regex</strong> expression <strong>replacing</strong> the <strong>S</strong>earch <strong>R</strong>egex</p>
</li>
</ul>
<p dir="auto">Note that, when the <strong>ER</strong> zone is <strong>not</strong> needed , these S/R can be simplified as :</p>
<p dir="auto">SEARCH <strong><code>(?-s)(</code>BR<code>|\G).*?\K</code>SR</strong>        OR        <strong><code>(?s)(</code>BR<code>|\G).*?\K</code>SR</strong></p>
<hr />
<p dir="auto">For instance :</p>
<ul>
<li>
<p dir="auto">In the regex <strong>A</strong>, <strong>BR</strong> = <strong><code>&lt;My Tag&gt;</code></strong>, <strong>ER</strong> = <strong><code>^&lt;</code></strong>, <strong>SR</strong> = <strong>EMPTY</strong> string between <strong><code>&lt;a\ href="</code></strong> and <strong><code>/</code></strong>, <strong>RR</strong> = <strong><code>https://link.ca</code></strong></p>
</li>
<li>
<p dir="auto">In the regex <strong>B</strong>, <strong>BR</strong> = <strong><code>&lt;!-- BEGIN --&gt;</code></strong>, <strong>ER</strong> = <strong><code>^&lt;</code></strong>, <strong>SR</strong> = <strong>EMPTY</strong> string between <strong><code>&lt;a\ href="</code></strong> and <strong><code>/</code></strong>, <strong>RR</strong> = <strong><code>https://link.ca</code></strong></p>
</li>
<li>
<p dir="auto">In the regex <strong>C</strong>, <strong>BR</strong> = <strong><code>&lt;p\ class="ONE"&gt;</code></strong>, <strong>ER</strong> = <strong><code>None</code></strong>, <strong>SR</strong> = <strong><code>\h*!\h*</code></strong>, <strong>RR</strong> = <strong><code>\x20!\x20</code></strong></p>
</li>
</ul>
<p dir="auto">Note that :</p>
<ul>
<li>
<p dir="auto">In regexes <strong>A</strong> and <strong>B</strong>, due to the <strong>muti-lines</strong> search with the leading <strong><code>(?s)</code></strong> modifier, an <strong>E</strong>xcluding <strong>R</strong>egex is necessary to <strong>not</strong> overlap through an <strong>other</strong> section <strong><code>&lt;My Tag&gt;</code></strong> or <strong><code>&lt;!-- BEGIN --&gt;</code></strong>, starting at <strong>beginning</strong> of line. Hence the <strong>negative</strong> look-ahead <strong><code>(?!^&lt;)</code></strong> in the expression <strong><code>((?!^&lt;).)+?</code></strong></p>
</li>
<li>
<p dir="auto">in regex <strong>C</strong>, the <strong>E</strong>xcluded <strong>R</strong>egex is <strong>implicit</strong> as it could be written with the <strong>negative</strong> look-ahead <strong><code>(?![\r\n])</code></strong> which is applied to <strong>each</strong> character of the <strong>shortest</strong> range <strong><code>.*?</code></strong> , hence the syntax <strong><code>((?![\r\n]).)*?</code></strong>. Indeed, because of the leading <strong><code>(?-s)</code></strong> modifier, any char of that range will <strong>never</strong> be an <strong>EOL</strong> character. So, it defines, <strong>implicitly</strong>, a zone after the string <strong><code>&lt;p\ class="ONE"&gt;</code></strong> till the first <strong><code>&lt;/p&gt;</code></strong> <strong>included</strong>, where to search for <strong><code>\h*!\h*</code></strong> and the <strong>shortest</strong> range of any <strong>standard</strong> characters can just be defined with the simple syntax <strong><code>(?-s).*?</code></strong> !</p>
</li>
</ul>
<p dir="auto">Best Regards,</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/61598</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/61598</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Sat, 23 Jan 2021 21:40:40 GMT</pubDate></item><item><title><![CDATA[Reply to Select all exclamation marks ! from a specific html tag on Sun, 10 Jan 2021 07:27:36 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/7377">@Alan-Kilborn</a> you can compare also the solutions on both topics, see yourself if is the same and if it can be applied in the same context :)</p>
]]></description><link>https://community.notepad-plus-plus.org/post/61594</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/61594</guid><dc:creator><![CDATA[Robin Cruise]]></dc:creator><pubDate>Sun, 10 Jan 2021 07:27:36 GMT</pubDate></item><item><title><![CDATA[Reply to Select all exclamation marks ! from a specific html tag on Sat, 09 Jan 2021 15:13:48 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/195">@guy038</a></p>
<p dir="auto">Isn’t this is just another variant on <a href="https://community.notepad-plus-plus.org/topic/20515/replace-words-between-tags-with-regular-expression/">THIS</a> ??</p>
]]></description><link>https://community.notepad-plus-plus.org/post/61563</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/61563</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Sat, 09 Jan 2021 15:13:48 GMT</pubDate></item><item><title><![CDATA[Reply to Select all exclamation marks ! from a specific html tag on Sat, 09 Jan 2021 14:50:31 GMT]]></title><description><![CDATA[<p dir="auto">thank you very much</p>
]]></description><link>https://community.notepad-plus-plus.org/post/61561</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/61561</guid><dc:creator><![CDATA[Robin Cruise]]></dc:creator><pubDate>Sat, 09 Jan 2021 14:50:31 GMT</pubDate></item><item><title><![CDATA[Reply to Select all exclamation marks ! from a specific html tag on Sat, 09 Jan 2021 14:42:39 GMT]]></title><description><![CDATA[<p dir="auto">Hello, <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/7753">@robin-cruise</a> and <strong>All</strong>,</p>
<p dir="auto">I suppose that the following <strong>regex</strong> S/R should do the trick :</p>
<p dir="auto">SEARCH <strong><code>(?i-s)(?:&lt;p class="ONE"&gt;|\G).*?\K\h*!\h*</code></strong></p>
<p dir="auto">REPLACE <strong><code>\x20!\x20</code></strong></p>
<p dir="auto">Here are the <strong>key</strong> points and steps :</p>
<ul>
<li>
<p dir="auto">We want to look for any <strong>exclamation mark</strong>, possibly <strong>preceded</strong> and/or <strong>followed</strong> with <strong>horizontal blanks</strong> characters ( the <strong>character class</strong> <strong><code>[\t\x20\xA0]</code></strong> ) so the simple regex <strong><code>\h*!\h*</code></strong> and replace it with an <strong>exclamation mark</strong> surrounded with a <strong>space</strong> char so the regex <strong><code>\x20!\x20</code></strong></p>
</li>
<li>
<p dir="auto">We also want to do this search <em>ONLY IF</em>  the tag is <strong><code>&lt;p class="ONE"&gt;</code></strong>. As, in your example, you’re using the <strong>upper</strong> and <strong>lower</strong> case, I suppose that the correct regex should be <strong><code>(?i)&lt;p class="ONE"&gt;</code></strong>, with a search <strong><code>I</code>nsensible</strong> to case. If not, use <strong>either</strong> <strong><code>(?-i)&lt;p class="ONE"&gt;</code></strong> or <strong><code>(?-i)&lt;p class="one"&gt;</code></strong></p>
</li>
<li>
<p dir="auto">Now, the <strong>main</strong> idea is :</p>
<ul>
<li>
<p dir="auto">To look for the <strong>shortest</strong> range of <strong>standard</strong> characters between the tag <strong><code>&lt;p class="ONE"&gt;</code></strong> and our <strong>searched</strong> expression <strong><code>\h*!\h*</code></strong>,  with the <strong>lazy</strong> quantifier <strong><code>*?</code></strong> and select only the <strong>searched</strong> expression, with the <strong><code>\K</code></strong> feature, so the regex <strong><code>(?i-s)&lt;p class="ONE"&gt;.*?\K\h*!\h*</code></strong></p>
</li>
<li>
<p dir="auto">To look, again, for the <strong>shortest</strong> range of <strong>standard</strong> chars from the position <strong>right after</strong> the <strong>end</strong> of the <strong>previous</strong> match, with the <strong><code>\G</code></strong> assertion and our <strong>searched</strong> expression, with the regex <strong><code>\G.*?\K\h*!\h*</code></strong></p>
</li>
<li>
<p dir="auto">And so on… … If we factor the <strong>anchor</strong> of the characters <strong>range</strong>, which is either <strong><code>&lt;p class="ONE"&gt;</code></strong> or <strong><code>\G</code></strong>, we end with the regex <strong><code>(?i-s)(?:&lt;p class="ONE"&gt;|\G).*?\K\h*!\h*</code></strong>, as above !</p>
</li>
</ul>
</li>
<li>
<p dir="auto">The <strong>important</strong> point to understand is that the <strong>range</strong> of chars, before reaching the <strong>searched</strong> expression, consists of <strong>standard</strong> characters. So, when the <strong>end</strong> of tag <strong><code>&lt;p class="ONE"&gt;...........&lt;/p&gt;</code></strong> is reached, the only way to go on is to <strong>skip</strong> the <strong><code>EOL</code></strong> characters, located after <strong><code>&lt;/p&gt;</code></strong>. But, in that case, the <strong><code>\G</code></strong> assertion is <strong>not</strong> verified anymore and, necessarily, the <strong>next</strong> match will have, <strong>first</strong>, to search for the <strong>other</strong> anchor <strong><code>&lt;p class="ONE"&gt;</code></strong> !</p>
</li>
</ul>
<hr />
<p dir="auto">If we use the <strong><code>free-spacing</code></strong> mode, our regex can be expressed as :</p>
<pre><code class="language-z">
(?xi-s)               #  FREE-SPACING mode, INSENSIBLE to case, any DOT = 1 STANDARD character ONLY
(?:                   #  NON-CAPTURING group
  &lt;p\ class="ONE"&gt;    #    LITERAL string &lt;p class="ONE"&gt; ( Note the ESCAPED SPACE char, after &lt;p )
|                     #  The ALTERNATION symbol
  \G                  #    MATCHES the position RIGHT AFTER the PREVIOUS match, ONLY
)                     #  End of the NON-CAPTURING group
 .*?                  #  The SHORTEST range, possiblY NUL, of STANDARD characters till ...
 \K                   #  CANCELS any MATCH so far and RESETS the regex ENGINE position to PRESENT position
\h*  !  \h*           #  ... the SEARCHED expression, so an EXCLAMATION MARK, possibly PRECEDED and/or FOLLOWED with HORIZONTAL BLANK characters
</code></pre>
<p dir="auto">Best Regards,</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/61560</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/61560</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Sat, 09 Jan 2021 14:42:39 GMT</pubDate></item></channel></rss>