<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[regex: Find all lines starting with a specific tag and ending with a different tag]]></title><description><![CDATA[<p dir="auto">I want to Find all lines starting with a specific tag and ending with a different tag. For example:</p>
<p dir="auto">&lt;p class=“amigo”&gt;My mother is at home.&lt;br&gt;</p>
<p dir="auto">tried a regex, but doesn’t work to good, because the selection does not stop at &lt;br&gt;</p>
<p dir="auto"><code>.*&lt;p class="amigo"&gt;(?s)(.*)&lt;br&gt;*$</code></p>
<p dir="auto">Can anyone help me?</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/16817/regex-find-all-lines-starting-with-a-specific-tag-and-ending-with-a-different-tag</link><generator>RSS for Node</generator><lastBuildDate>Wed, 22 Apr 2026 02:07:14 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/16817.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 20 Dec 2018 06:38:08 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to regex: Find all lines starting with a specific tag and ending with a different tag on Wed, 26 Dec 2018 00:34:05 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> and <strong>All</strong>,</p>
<p dir="auto">Regarding <strong>regex operators precedence</strong>, taken from the link,</p>
<p dir="auto"><a href="https://www.boost.org/doc/libs/1_55_0/libs/regex/doc/html/boost_regex/syntax/perl_syntax.html#boost_regex.syntax.perl_syntax.operator_precedence" rel="nofollow ugc">https://www.boost.org/doc/libs/1_55_0/libs/regex/doc/html/boost_regex/syntax/perl_syntax.html#boost_regex.syntax.perl_syntax.operator_precedence</a></p>
<p dir="auto">The table, below, gives the <strong>hierarchy</strong> of these operators, listed from the <strong>highest</strong> priority to the <strong>lowest</strong> priority :</p>
<ol>
<li><strong>POSIX</strong> based <strong>Bracket Character</strong> set : <strong><code>[:Class character:]</code></strong>, <strong><code>[=Equivalent Class=]</code></strong>, and <strong><code>[.Collating element.]</code></strong></li>
<li><strong>Escaped</strong> characters : <strong><code>\...</code></strong></li>
<li><strong>Bracket Character</strong> set, ( <strong>negative</strong> or <strong>not</strong> ) : <strong><code>[^.....]</code></strong> and <strong><code>[.....]</code></strong></li>
<li><strong>Grouping</strong>, ( <strong>capturing</strong> or <strong>not</strong> ) : <strong><code>(.....)</code></strong> and <strong><code>(?:.....)</code></strong></li>
<li><strong>Quantifiers</strong> : <strong><code>*</code></strong>, <strong><code>+</code></strong>, <strong><code>?</code></strong>,  <strong><code>{n}</code></strong>,  <strong><code>{m,n}</code></strong> and  <strong><code>{m,}</code></strong></li>
<li><strong>Concatenation</strong> ( Implicit )</li>
<li><strong>Anchoring</strong> : <strong><code>^</code></strong> and <strong><code>$</code></strong></li>
<li><strong>Alternation</strong> : <strong><code>|</code></strong></li>
</ol>
<hr />
<p dir="auto">Here are some <strong>examples</strong> to verify this <strong>hierarchy</strong> :</p>
<ul>
<li>Between level <strong>1</strong> and level <strong>2</strong> :</li>
</ul>
<p dir="auto">The regex <strong><code>&lsqb;&lsqb;=\=&rsqb;&rsqb;</code></strong> matches the <strong>reversed slash</strong> <strong><code>\</code></strong>, only and <strong>NOT</strong> the regex <strong><code>&lsqb;&lsqb;==&rsqb;&rsqb;</code></strong>, which is, besides, <strong>invalid</strong> !</p>
<ul>
<li>Between level <strong>2</strong> and level <strong>3</strong> :</li>
</ul>
<p dir="auto">The regex <strong><code>\[1]</code></strong> means the regex <strong><code>\[</code></strong> , so the string <strong>[</strong>, followed with the string <strong>1]</strong> and <strong>NOT</strong> the regex <strong><code>\1</code></strong>, as <strong><code>[1]</code></strong> represents the <strong>1</strong> digit., which,finally, matches the <strong>1</strong> digit</p>
<ul>
<li>Between level <strong>3</strong> and level <strong>4</strong> :</li>
</ul>
<p dir="auto">The regex <strong><code>[(123)45]</code></strong> matches <strong>1</strong>, <strong>2</strong>, <strong>3</strong>, <strong>4</strong> and <strong>5</strong> digits, as well as the <strong>parentheses</strong> <strong><code>(</code></strong> and <strong><code>)</code></strong>, and <strong>NOT</strong> the number <strong>123</strong>, as a <strong>group</strong>, or the digits <strong>4</strong> or <strong>5</strong>, which can be found with the regex <strong><code>(123)|[45]</code></strong></p>
<ul>
<li>Between level <strong>4</strong> and level <strong>5</strong> :</li>
</ul>
<p dir="auto">The regex <strong><code>(123)+</code></strong> represents the number <strong>123</strong>, possibly <strong>repeated</strong>, and <strong>NOT</strong> the <strong>12</strong> number, followed with <strong>any</strong> range of <strong>consecutive</strong> digit(s) <strong>3</strong>, which can be found with the regex <strong><code>123+</code></strong></p>
<ul>
<li>Between level <strong>5</strong> and level <strong>6</strong> :</li>
</ul>
<p dir="auto">The regex <strong><code>123+45+</code></strong> matches the <strong>12</strong> number, followed with <strong>any</strong> range of <strong>consecutive</strong> digit(s) <strong>3</strong>, followed with <strong>4</strong> number, followed with <strong>any</strong> range of <strong>consecutive</strong> digit(s) <strong>5</strong> and NOT <strong>any</strong> range of the <strong>123</strong> number, followed with <strong>any</strong> range of the <strong>45</strong> number, which can be obtained with the regex <strong><code>(123)+(45)+</code></strong></p>
<ul>
<li>Between level <strong>6</strong> and level <strong>7</strong> :</li>
</ul>
<p dir="auto">I have <strong>not</strong> been able to detail <strong>differences</strong> between implicit <strong>concatenation</strong> of regexes ( for instance, regex <strong><code>a</code></strong>, followed with regex <strong><code>b</code></strong> resulting in the regex <strong><code>ab</code></strong> ) and <strong>anchoring</strong> which defines <strong>zero-length</strong> regexes, matching <strong>specific</strong> locations in file contents !</p>
<p dir="auto">Indeed, if we consider the simple regex <strong><code>^123</code></strong>, to my mind, the regex <strong><code>^1</code></strong>, <strong>immediately</strong> followed with the regex <strong><code>23</code></strong> or the regex <strong><code>^12</code></strong>, <strong>immediately</strong> followed with the regex <strong><code>3</code></strong> and the regex <strong><code>^123</code></strong>, or even the <strong>zero-lengh</strong> regex <strong><code>^</code></strong> followed with the regex <strong><code>123</code></strong>, seem all <strong>identical</strong> !?</p>
<p dir="auto">A bit <strong>off topic</strong> : just notice that <strong>string concatenation</strong> does NOT represent the <strong>same</strong> concept as <strong>regex concatenation</strong> ! For instance, the regex <strong><code>[12]</code></strong>, followed with the regex <strong><code>[34]</code></strong> matches all elements of the set <strong><code>{</code></strong> <strong>13</strong>, <strong>14</strong>, <strong>23</strong>, <strong>24</strong> <strong><code>}</code></strong>, whereas the string <strong>12</strong>, followed with string <strong>34</strong>, represents the <strong>single</strong>-element set <strong><code>{</code></strong> <strong>1234</strong> <strong><code>}</code></strong></p>
<ul>
<li>Between level <strong>7</strong> and level <strong>8</strong> :</li>
</ul>
<p dir="auto">The regex <strong><code>^12|34$</code></strong> matches the <strong>12</strong> number, <strong>beginning</strong> a line OR the <strong>34</strong> number, <strong>ending</strong> a line ( and NOT a line with number <strong>12</strong> OR number <strong>34</strong>, only ( which can be found  with the regex <strong><code>^(12|34)$</code></strong> ) NEITHER a line <strong>beginning</strong> with the <strong>1</strong> digit, <strong>ending</strong> with the <strong>4</strong> digit and between, either, digit <strong>2</strong> OR <strong>3</strong> ( which can be found with the regex <strong><code>^1(2|3)4$</code></strong> )</p>
<p dir="auto">Best regards,</p>
<p dir="auto"><strong>Merry Christmas</strong> and <strong>Happy Holidays</strong> to all  ;-))</p>
<p dir="auto">guy038</p>
<p dir="auto"><strong>P.S.</strong> :</p>
<p dir="auto">I’ve, also, found out a <strong>great</strong> article on <strong>operators precedence</strong>, regarding the main <strong>progamming</strong> or <strong>script</strong> languages ;-)) Just click below :</p>
<p dir="auto"><a href="https://rosettacode.org/wiki/Operator_precedence" rel="nofollow ugc">https://rosettacode.org/wiki/Operator_precedence</a></p>
]]></description><link>https://community.notepad-plus-plus.org/post/37788</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/37788</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Wed, 26 Dec 2018 00:34:05 GMT</pubDate></item><item><title><![CDATA[Reply to regex: Find all lines starting with a specific tag and ending with a different tag on Fri, 21 Dec 2018 20:56:04 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 think I see what you are saying.  You are saying that to some people with misunderstanding would think that the <code>(?i)</code> only affects <code>friday</code> in the example above.</p>
<p dir="auto">In general this brings up a good point, or a question.  What is the precedence of regexes?</p>
<p dir="auto">For example if you have the regex <code>friday|saturday|sunday</code> we know that it truly means <code>(friday)|(saturday)|(sunday)</code> – without the capturing of course.  But it could mean <code>frida(y|s)aturda(y|s)unday</code> I suppose – but I know it doesn’t.  But I don’t know the real rules of when one needs non-capturing parens…and when one doesn’t.</p>
<p dir="auto">Maybe this is a hard question to ask, and it isn’t really Notepad++ related…</p>
]]></description><link>https://community.notepad-plus-plus.org/post/37772</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/37772</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Fri, 21 Dec 2018 20:56:04 GMT</pubDate></item><item><title><![CDATA[Reply to regex: Find all lines starting with a specific tag and ending with a different tag on Fri, 21 Dec 2018 19:13:49 GMT]]></title><description><![CDATA[<p dir="auto">Hi, <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/7753">@robin-cruise</a>, <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">Ah…, yes, <strong>Robin</strong>, you’re quite right ! It’s the usual <strong>drawback</strong> of finding out a regex, <strong>without</strong> having the <strong>real</strong> text to test the regex against !</p>
<p dir="auto">I’m not an <strong><code>HTML</code></strong> coder and, may be, I’m going to tell a <strong>nonsense</strong> but let’s suppose the following text, without the <strong>ending</strong> tag, at line <strong><code>4</code></strong>. So :</p>
<pre><code class="language-xml">&lt;p class=“amigo”&gt;1. Blah blah blah &lt;br&gt;
      2. Blah blah blah &lt;br&gt;
      3.  Blah blah blah &lt;br&gt;
      4.  Blah blah blah
      ....
</code></pre>
<p dir="auto">How can I <strong>decide</strong> between this case <strong>A</strong> :</p>
<pre><code class="language-xml">&lt;p class=“amigo”&gt;1. Blah blah blah &lt;/p&gt;
      2. Blah blah blah &lt;br&gt;
      3. Blah blah blah &lt;br&gt;
      4. Blah blah blah &lt;br&gt;
      ....
</code></pre>
<p dir="auto">And this case <strong>B</strong>, below ?</p>
<pre><code class="language-xml">&lt;p class=“amigo”&gt;1. Blah blah blah &lt;br&gt;
      2. Blah blah blah &lt;br&gt;
      3. Blah blah blah &lt;br&gt;
      4. Blah blah blah    &lt;/p&gt;
      ....
</code></pre>
<p dir="auto">Of course, feel free to send me an <strong>e-mail</strong>, with your <strong>true</strong> text, if you don’t mind, just telling me <strong>where</strong> you would like to replace the <strong><code>&lt;br&gt;</code></strong> with <strong><code>&lt;/p&gt;</code></strong></p>
<hr />
<p dir="auto">To <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/7377">@alan-kilborn</a>,</p>
<p dir="auto">Of course, I didn’t say that it was an <strong>hidden</strong> rule or a <strong>work-around</strong> ! I just wanted to point out, for beginners to “<strong>regex world</strong>”, the fact that, if the <strong>search</strong> pattern is an <strong>alternative</strong>, with <strong>several</strong> branches, either :</p>
<ul>
<li>
<p dir="auto">In a <strong>non-capturing</strong> group, as <strong><code>(?i:friday|saturday|sunday)</code></strong> or <strong><code>(?:(?i)friday|saturday|sunday)</code></strong></p>
</li>
<li>
<p dir="auto">In a <strong>capturing</strong> group, as <strong><code>((?i)friday|saturday|sunday)</code></strong></p>
</li>
</ul>
<p dir="auto">The <strong>modifier</strong>, <strong><code>(?i)</code></strong> in this example, affects <strong>any</strong> branch of the <strong>alternative</strong></p>
<p dir="auto">Best Regards,</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/37769</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/37769</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Fri, 21 Dec 2018 19:13:49 GMT</pubDate></item><item><title><![CDATA[Reply to regex: Find all lines starting with a specific tag and ending with a different tag on Fri, 21 Dec 2018 13:37:52 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">Because alternative branches are tried from left to right, and options are not reset until the end of the subpattern is reached, an option setting in one branch does affect subsequent branches</p>
</blockquote>
<p dir="auto">Is there something new or surprising here?</p>
<p dir="auto">In the example you gave, this part:</p>
<p dir="auto"><code>(?i:friday|saturday|sunday)</code></p>
<p dir="auto">It corresponds to my “revised Wiki” entry of:</p>
<p dir="auto"><code>(?flags:searchpattern)</code></p>
<p dir="auto">where in this case:</p>
<p dir="auto"><code>searchpattern</code> = <code>friday|saturday|sunday</code></p>
<p dir="auto">but it is still just a re pattern…</p>
<p dir="auto">I feel like I am missing something here because my first thought is of course this is the way it works and nothing is new here.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/37765</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/37765</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Fri, 21 Dec 2018 13:37:52 GMT</pubDate></item><item><title><![CDATA[Reply to regex: Find all lines starting with a specific tag and ending with a different tag on Fri, 21 Dec 2018 06:56:46 GMT]]></title><description><![CDATA[<p dir="auto">Thanks everyone for help.</p>
<p dir="auto">guyo38 made also a beautiful regex. But, there is a case where the formula does not fit. Suppose:</p>
<p dir="auto">Case 1</p>
<pre><code>&lt;p class=“amigo”&gt;1. Blah blah blah &lt;br&gt;
      2. Blah blah blah &lt;br&gt;
      3.  Blah blah blah &lt;br&gt;
      4.  Blah blah blah       &lt;/p&gt;
</code></pre>
<p dir="auto">Case 2</p>
<pre><code>&lt;p class=“amigo”&gt;1. Blah blah blah &lt;br&gt;
      2. Blah blah blah &lt;br&gt;
      3.  Blah blah blah &lt;br&gt;
      4.  Blah blah blah        &lt;br&gt;
 new sentence here &lt;/p&gt;
</code></pre>
<p dir="auto">In this 2 cases your regex <code>(?s)&lt;p class[^&lt;]+\K(?!&lt;/p&gt;)&lt;(?-s).+&gt;</code> replace by <code>&lt;/p&gt;</code> will replace the first instance of <code>&lt;br&gt;</code>, and that will ruin the html code.</p>
<p dir="auto">So, in this 2 cases, I would only like to search and replace only those tags that contains only one instance of <code>&lt;br&gt;</code>. Or, if there are more <code>&lt;br&gt;</code>, the replacement with <code>&lt;/p&gt;</code> would not take place anymore.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/37758</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/37758</guid><dc:creator><![CDATA[Robin Cruise]]></dc:creator><pubDate>Fri, 21 Dec 2018 06:56:46 GMT</pubDate></item><item><title><![CDATA[Reply to regex: Find all lines starting with a specific tag and ending with a different tag on Fri, 21 Dec 2018 06:12:21 GMT]]></title><description><![CDATA[<p dir="auto">Hi, all,</p>
<p dir="auto">May be a bit <strong>late</strong> but here is a <strong>regex</strong> S/R which is able to detect and replace any <strong>ending</strong> tag, different of <strong><code>&lt;/p&gt;</code></strong>, with this one, in any <strong>mono</strong> or <strong>multi</strong>-lines range <strong><code>&lt;p class.....&gt;.............&lt;...&gt;</code></strong>, <strong>whatever</strong> its location on current line</p>
<p dir="auto">SEARCH <strong><code>(?s)&lt;p class[^&lt;]+\K(?!&lt;/p&gt;)&lt;(?-s).+&gt;</code></strong></p>
<p dir="auto">REPLACE <strong><code>&lt;/p&gt;</code></strong></p>
<p dir="auto"><strong>Remark</strong> : I’s <strong>important</strong> to point out that, due to the <strong><code>\K</code></strong> syntax, this <strong>regex</strong> S/R works if you click on the <strong><code>Replace All</code></strong> button , <strong>exclusively</strong> ! ( Any <strong>step-by-step</strong> replacement , with the <strong><code>Replace</code></strong> button, will <strong>not</strong> work )</p>
<p dir="auto">So, assuming this <strong>test</strong> text :</p>
<pre><code class="language-xml">bla bla   &lt;p class=“amigo”&gt;My mother is at home.&lt;br&gt;   bla bla

bla blah

bla bla   &lt;p class=“amigo”&gt;My mother
 is at 

home.&lt;br&gt;   bla bla

bla blah

bla bla   &lt;p class=“amigo”&gt;My mother
 is at home.&lt;h&gt;   bla bla

bla blah

bla bla   &lt;p class=“amigo”&gt;My mother is at home.&lt;/p&gt;   ====== NOT CHANGED ======

bla blah

bla bla   &lt;p class=“amigo”&gt;My mother is at home.&lt;/h&gt;   bla bla

bla blah

bla bla   &lt;p class=“amigo”&gt;My
 mother
 is at
 home.&lt;/p&gt;   ====== NOT CHANGED ======

bla blah

bla bla   &lt;p class=“amigo”&gt;My mother is at home.&lt;/a&gt;   bla bla

bla blah

bla bla   &lt;p class=“amigo”&gt;My mother is at home.&lt;p&gt;   bla bla

bla blah

bla bla   &lt;p class=“amigo”&gt;My mother is at home.&lt;br&gt;   bla bla

bla blah
</code></pre>
<p dir="auto">You would obtain :</p>
<pre><code class="language-xml">bla bla   &lt;p class=“amigo”&gt;My mother is at home.&lt;/p&gt;   bla bla

bla blah

bla bla   &lt;p class=“amigo”&gt;My mother
 is at 

home.&lt;/p&gt;   bla bla

bla blah

bla bla   &lt;p class=“amigo”&gt;My mother
 is at home.&lt;/p&gt;   bla bla

bla blah

bla bla   &lt;p class=“amigo”&gt;My mother is at home.&lt;/p&gt;   ====== NOT CHANGED ======

bla blah

bla bla   &lt;p class=“amigo”&gt;My mother is at home.&lt;/p&gt;   bla bla

bla blah

bla bla   &lt;p class=“amigo”&gt;My
 mother
 is at
 home.&lt;/p&gt;   ====== NOT CHANGED ======

bla blah

bla bla   &lt;p class=“amigo”&gt;My mother is at home.&lt;/p&gt;   bla bla

bla blah

bla bla   &lt;p class=“amigo”&gt;My mother is at home.&lt;/p&gt;   bla bla

bla blah

bla bla   &lt;p class=“amigo”&gt;My mother is at home.&lt;/p&gt;   bla bla

bla blah
</code></pre>
<p dir="auto">Best regards,</p>
<p dir="auto">guy038</p>
<p dir="auto"><strong>P.S.</strong> : To continue the <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/7377">@alan-kilborn</a> discussion on <strong>flags</strong>, from the link below :</p>
<p dir="auto"><a href="https://gammon.com.au/pcre/pcrepattern.html#SEC11" rel="nofollow ugc">https://gammon.com.au/pcre/pcrepattern.html#SEC11</a></p>
<p dir="auto">It is said :</p>
<p dir="auto">Because <strong>alternative</strong> branches are tried from <strong>left</strong> to <strong>right</strong>, and options are <strong>not</strong> reset until the <strong>end</strong> of the subpattern is reached, an option setting in <strong>one</strong> branch does affect <strong>subsequent</strong> branches</p>
<p dir="auto">So, for instance, the regex <strong><code>(?-i)WEDNESDAY|(?i:friday|saturday|sunday)|Monday</code></strong> would match :</p>
<ul>
<li>
<p dir="auto"><strong>WEDNESDAY</strong> and <strong>Monday</strong>, in that <strong>exact</strong> case</p>
</li>
<li>
<p dir="auto"><strong>Friday</strong>, as well as <strong>Saturday</strong> and <strong>Sunday</strong> in <strong>any</strong> case</p>
</li>
</ul>
]]></description><link>https://community.notepad-plus-plus.org/post/37757</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/37757</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Fri, 21 Dec 2018 06:12:21 GMT</pubDate></item><item><title><![CDATA[Reply to regex: Find all lines starting with a specific tag and ending with a different tag on Thu, 20 Dec 2018 21:21:36 GMT]]></title><description><![CDATA[<p dir="auto">Continues to blah, blah, blah on and on…</p>
<p dir="auto">So checking the Notepad++ regex wiki: <a href="http://docs.notepad-plus-plus.org/index.php/Regular_Expressions" rel="nofollow ugc">http://docs.notepad-plus-plus.org/index.php/Regular_Expressions</a></p>
<p dir="auto">I see that this syntax IS there, but I guess I never understood it because it is SO f*cked up.  :-)</p>
<p dir="auto">Here’s what the Wiki says:</p>
<pre><code>(?:flags-not-flags ...), (?:flags-not-flags:...)
Applies flags and not-flags to search inside the parentheses. Such a construct may have flags and may have not-flags - if it has neither, it is just a non-marking group, which is just a readability enhancer.
</code></pre>
<p dir="auto">Here’s how I would write it so that it is (hopefully) understandable:</p>
<pre><code>(?flags-notflags:searchpattern)
Applies flags and notflags to the searchpattern inside the parentheses and forms a non-capturing group. Such a construct may optionally have flags and may optionally have -notflags ; if it has neither, it is just a simple non-capturing group.  Note that the effect of flags/nonflags only applies to the searchpattern inside the enclosing parentheses.
</code></pre>
]]></description><link>https://community.notepad-plus-plus.org/post/37749</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/37749</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Thu, 20 Dec 2018 21:21:36 GMT</pubDate></item><item><title><![CDATA[Reply to regex: Find all lines starting with a specific tag and ending with a different tag on Thu, 20 Dec 2018 21:02:12 GMT]]></title><description><![CDATA[<p dir="auto">But I did learn something new from Peter’s post, that does work with Boost.  I didn’t know that you could include a <code>:pattern</code> inside, for example, <code>(?i)</code>.  So it is perfectly legal to do this:</p>
<p dir="auto"><code>(?-i)b(?i:b)b</code> to match <code>bbb</code> or <code>bBb</code> but not <code>Bbb</code>, <code>BBB</code>, <code>bBB</code>, etc.</p>
<p dir="auto">Note that the <code>?i</code> only applies to what is inside the enclosing round brackets.  After the closing one, the outer leading <code>(?-i)</code> goes back into being in effect.</p>
<p dir="auto">Before this new knowledge I would have achieved the same thing this way: <code>(?-i)b((?i)b)b</code> or even messier <code>(?-i)b(?:(?i)b)b</code> or <code>(?-i)b(?i)b(?-i)b</code></p>
<p dir="auto">Note also that <code>(?i:pattern)</code> is a non-capturing group.  And <code>i</code> could be <code>s</code> or whatever is legal (see prior post).</p>
<p dir="auto">Before some wiseguy points out that <code>b[bB]b</code> works just as well…these are just made up examples to show a technique, not true real-life searches.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/37747</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/37747</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Thu, 20 Dec 2018 21:02:12 GMT</pubDate></item><item><title><![CDATA[Reply to regex: Find all lines starting with a specific tag and ending with a different tag on Thu, 20 Dec 2018 20:22:51 GMT]]></title><description><![CDATA[<p dir="auto">Be careful here.  Notepad++ doesn’t use PCRE regular expressions, no mater what the N++ wiki says.  It uses Boost regular expressions.</p>
<p dir="auto">Of these:</p>
<p dir="auto">(?adluimnsx-imnsx)</p>
<p dir="auto">Boost does not support adlun, reducing what it does support to:</p>
<p dir="auto">(?imsx-imsx)</p>
<p dir="auto">If used one of the invalid ones, Notepad++ will say “Find: Invalid regular expression”</p>
]]></description><link>https://community.notepad-plus-plus.org/post/37745</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/37745</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Thu, 20 Dec 2018 20:22:51 GMT</pubDate></item><item><title><![CDATA[Reply to regex: Find all lines starting with a specific tag and ending with a different tag on Thu, 20 Dec 2018 20:13:50 GMT]]></title><description><![CDATA[<p dir="auto">Sorry <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/7753">@Robin-Cruise</a> Peter explained the confusion well.<br />
<a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/3841">@PeterJones</a> said:</p>
<blockquote>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/12335">@Terry-R</a> used the word “bracketed” to mean…</p>
</blockquote>
<p dir="auto">Yes I meant the “round brackets” <code>(</code> and <code>)</code>. As Peter stated there are SO many different varieties it’s very easy to get confused. Your regex101 link above would have shown you what each capture group referred to and there were the “round brackets” mentioned.</p>
<p dir="auto">I would strongly suggest you study the various characters used that have special meaning, following the links above that Peter and myself mentioned. Unless you get these basics sorted you will have ALL sorts of problems trying to create regexes successfully.</p>
<p dir="auto">Terry</p>
]]></description><link>https://community.notepad-plus-plus.org/post/37744</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/37744</guid><dc:creator><![CDATA[Terry R]]></dc:creator><pubDate>Thu, 20 Dec 2018 20:13:50 GMT</pubDate></item><item><title><![CDATA[Reply to regex: Find all lines starting with a specific tag and ending with a different tag on Thu, 20 Dec 2018 20:12:05 GMT]]></title><description><![CDATA[<p dir="auto"><a href="http://Regexr.com" rel="nofollow ugc">Regexr.com</a> calls <code>(?-s)</code> a “mode modifier”.</p>
<p dir="auto">PCRE (Perl Compatible Regular Expresions) have their origin in Perl, and I learned my regex through Perl, so when I’m confused, I go to <a href="http://perldoc.perl.org/perlre.html" rel="nofollow ugc">Perl’s perlre manpage</a>.  That shows a fully-expanded non-capturing group with enabled modifiers, disabled modifiers, and a non-capturing pattern: <code>(?adluimnsx-imnsx:pattern)</code></p>
<ul>
<li><code>adluimnsx</code> are the possible pattern modifiers to enable (where you can have 0 or more of the modifiers),</li>
<li><code>-imnsx</code> are the possible pattern modifiers to disable (where you can have 0 or more of the modifiers after the <code>-</code>),</li>
<li><code>pattern</code> is the part of the regex pattern that you want to group and match, but not capture.</li>
<li>If you don’t have modifiers, it shortens to <code>(?:pattern)</code>;</li>
<li>if you don’t have a pattern and just want modifiers, it shortens to <code>(?adluimnsx-imnsx)</code>.</li>
</ul>
]]></description><link>https://community.notepad-plus-plus.org/post/37743</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/37743</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Thu, 20 Dec 2018 20:12:05 GMT</pubDate></item><item><title><![CDATA[Reply to regex: Find all lines starting with a specific tag and ending with a different tag on Thu, 20 Dec 2018 20:00:21 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/7753">@Robin-Cruise</a> ,</p>
<p dir="auto">Oh, I think I just realized your confusion.  <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/12335">@Terry-R</a> used the word “bracketed” to mean “surrounded by parentheses <code>(...)</code>”, but you interpreted it to mean “surrounded by angle brackets <code>&lt;...&gt;</code>”.</p>
<p dir="auto">Given different people’s terminology in reference to parentheses/parenthesis, braces, brackets, curly brackets, square brackets, angle brackets, I try to be as explicit as possible, and often give examples of which I mean (though I sometimes fail at this).</p>
]]></description><link>https://community.notepad-plus-plus.org/post/37741</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/37741</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Thu, 20 Dec 2018 20:00:21 GMT</pubDate></item><item><title><![CDATA[Reply to regex: Find all lines starting with a specific tag and ending with a different tag on Thu, 20 Dec 2018 19:57:39 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/7753">@Robin-Cruise</a> said:</p>
<blockquote>
<p dir="auto">But please, so to understand better this replace on your regex</p>
</blockquote>
<p dir="auto">I think you misunderstand the brackets around the <code>?-s</code>. This is NOT a capture group, it is a modifier (I think that’s the correct wording). It modifies the parameters that the regex uses when searching for text. The first bracket for capturing is the one for the opening tag sequence <code>(.*&lt;p class="amigo"&gt;.*)</code>.</p>
<p dir="auto">Might I suggest you need to read up a bit more on what metacharacter sequences are used in regex to modify the parameters. This site I use often and has good examples.<br />
<a href="http://rexegg.com/regex-quickstart.html" rel="nofollow ugc">http://rexegg.com/regex-quickstart.html</a><br />
Bear in mind that most regex engines will be slightly different in how they use these metacharacters so not everything on this site will fit exactly to how Notepad++ works, but nonetheless the information is still helpful.</p>
<p dir="auto">Terry</p>
]]></description><link>https://community.notepad-plus-plus.org/post/37740</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/37740</guid><dc:creator><![CDATA[Terry R]]></dc:creator><pubDate>Thu, 20 Dec 2018 19:57:39 GMT</pubDate></item><item><title><![CDATA[Reply to regex: Find all lines starting with a specific tag and ending with a different tag on Thu, 20 Dec 2018 19:57:06 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/7753">@Robin-Cruise</a>,</p>
<p dir="auto">The regex <code>(?-s)(.*&lt;p class="amigo"&gt;.*)&lt;br&gt;(.*)$</code> only has two capturing parenthesis-pairs.  The <code>(?-s)</code> is a non-capturing command to the regex engine, and doesn’t capture anything.  The next parenthesized group <em>is</em>  a capture group, and captures the <code>...&lt;p...&gt;...</code> into <code>\1</code>.  The <code>&lt;br&gt;</code> is not captured (it’s not inside parentheses).  The next parenthesized group is a capture group, and grabs everything beyond the <code>&lt;br&gt;</code> to the end of the line.</p>
<pre><code>(?-s)(.*&lt;p class="amigo"&gt;.*)&lt;br&gt;(.*)$
^^^^^ = not a capture group (it's a command to regex)

(?-s)(.*&lt;p class="amigo"&gt;.*)&lt;br&gt;(.*)$
     ^^^^^^^^^^^^^^^^^^^^^^^ = first capture group, into \1

(?-s)(.*&lt;p class="amigo"&gt;.*)&lt;br&gt;(.*)$
                            ^^^^ = not in parentheses, so not captured

(?-s)(.*&lt;p class="amigo"&gt;.*)&lt;br&gt;(.*)$
                                ^^^^ = second capture group, into \2
</code></pre>
<p dir="auto">-----<br />
<a href="https://notepad-plus-plus.org/community/topic/15765/faq-desk-where-to-find-regex-documentation" rel="nofollow ugc">This FAQ</a> gives lots of good pointers to regex documentation.  You can study more about regular expressions and capture groups vs. non-capture groups in the links provided there.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/37739</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/37739</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Thu, 20 Dec 2018 19:57:06 GMT</pubDate></item><item><title><![CDATA[Reply to regex: Find all lines starting with a specific tag and ending with a different tag on Thu, 20 Dec 2018 19:37:31 GMT]]></title><description><![CDATA[<p dir="auto">great, thanks. But please, so to understand better this replace on your regex :<code>(?-s)(.*&lt;p class="amigo"&gt;.*)&lt;br&gt;(.*)$</code></p>
<p dir="auto">so,</p>
<p dir="auto"><code>\1</code> is the first bracket<br />
<code>\2</code> second bracket<br />
<code>\3</code> third bracket</p>
<p dir="auto">but, If I replace your regex just with  <code>\1</code>it will delete <code>&lt;br&gt;</code><br />
So, seems to me that those <code>\1 \2 \3 ..</code>  selects the words/code which is not in brackets. Correct ?</p>
]]></description><link>https://community.notepad-plus-plus.org/post/37738</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/37738</guid><dc:creator><![CDATA[Robin Cruise]]></dc:creator><pubDate>Thu, 20 Dec 2018 19:37:31 GMT</pubDate></item><item><title><![CDATA[Reply to regex: Find all lines starting with a specific tag and ending with a different tag on Thu, 20 Dec 2018 18:57:17 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/7753">@Robin-Cruise</a><br />
When replacing you need to capture text that you want to return, this is achieved by using <code>(</code> and <code>)</code> around those portions. Then in the replace field you use the <code>\1</code>, <code>\2</code> etc to return them.<br />
So for your need to replace the <code>&lt;br&gt;</code>, we don’t need brackets around it, but around the other text.<br />
Find what:<code>(?-s)(.*&lt;p class="amigo"&gt;.*)&lt;br&gt;(.*)$</code><br />
Replace with:<code>\1&lt;/p&gt;\2</code></p>
<p dir="auto">Note that the following portion (after the &lt;br&gt;) is now bracketed. Although none of the examples actually show any text following the &lt;br&gt;, if any did occur they would be captured and returned.</p>
<p dir="auto">Terry</p>
]]></description><link>https://community.notepad-plus-plus.org/post/37734</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/37734</guid><dc:creator><![CDATA[Terry R]]></dc:creator><pubDate>Thu, 20 Dec 2018 18:57:17 GMT</pubDate></item><item><title><![CDATA[Reply to regex: Find all lines starting with a specific tag and ending with a different tag on Thu, 20 Dec 2018 18:03:30 GMT]]></title><description><![CDATA[<p dir="auto">yes, nice Peter your solution <code>(?-s).*&lt;p class="amigo"&gt;(.*)&lt;br&gt;.*$</code></p>
<p dir="auto">Ok, but if I want to make this search and replace just the <code>&lt;br&gt;</code> from all those lines, how can I do this?</p>
<p dir="auto">So, to find all lines that contains those 2 tags, and replace only tha last one, <code>&lt;br&gt;</code> with <code>&lt;/p&gt;</code> Something like this, but not too good:</p>
<p dir="auto">Search:  <code>(?-s).*&lt;p class="amigo"&gt;(.*)(&lt;br&gt;).*$</code></p>
<p dir="auto">Replace by: <code>1\2\3&lt;/p&gt;</code></p>
<p dir="auto">Can you help me a little bit?</p>
]]></description><link>https://community.notepad-plus-plus.org/post/37733</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/37733</guid><dc:creator><![CDATA[Robin Cruise]]></dc:creator><pubDate>Thu, 20 Dec 2018 18:03:30 GMT</pubDate></item><item><title><![CDATA[Reply to regex: Find all lines starting with a specific tag and ending with a different tag on Thu, 20 Dec 2018 17:12:37 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> beat me to the <code>(?s)(?-s)</code>… but if you just drop both, then</p>
<pre><code>&lt;p class="amigo"&gt;My mother is at home.&lt;p&gt;

asdas

&lt;p class="amigo"&gt;My mother is at home.&lt;br&gt;

asfa

asffa
</code></pre>
<p dir="auto">will match from the first p-amigo line to the end of the <code>...&lt;br&gt;</code> line.<br />
The examples I showed will correct that, too.</p>
<p dir="auto"><strong>edit</strong>: this is true only if dot-matches-newline checkbox is turned on in the dialog, of course…  if it’s turned off, then it doesn’t matter whether .* is greedy or not. (<strong>edits #2-n</strong>: clarified wording a couple times)</p>
]]></description><link>https://community.notepad-plus-plus.org/post/37732</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/37732</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Thu, 20 Dec 2018 17:12:37 GMT</pubDate></item><item><title><![CDATA[Reply to regex: Find all lines starting with a specific tag and ending with a different tag on Thu, 20 Dec 2018 17:06:20 GMT]]></title><description><![CDATA[<p dir="auto">The <strong>reason</strong> why adding the <code>(?-s)</code> worked for you: originally, you had set “dot matches newline” using <code>(?s)</code>, so your <code>(.*)</code> greedily matched everything (including newlines) from start of the first amigo-paragraph to the last line-ending-<code>&lt;br&gt;</code> that it found.  By turning off “dot matches newline” with <code>(?-s)</code>, then it would only match when the <code>&lt;br&gt;</code> occurs on the same line as the amigo-paragraph.</p>
<p dir="auto">A couple of nitpicks with your solution:</p>
<ol>
<li>
<p dir="auto"><code>(?s)</code> and <code>(?-s)</code> are opposites: by having one followed by the other, this turns on “dot matches newline” then <strong>immediately</strong> turns off “dot matches newline”.  You just need <code>(?-s)</code> to turn it off.</p>
</li>
<li>
<p dir="auto"><code>&lt;br&gt;*$</code>: this matches the literals <code>&lt;</code>, <code>b</code>, <code>r</code>, followed by 0 or more occurrences of <code>&gt;</code>, followed by end of line.  Which means it would match <code>&lt;br</code>, or <code>&lt;br&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;</code>, not just <code>&lt;br&gt;</code>.</p>
</li>
<li>
<p dir="auto"><code>&gt;*$</code>: Also, because of the <code>$</code> anchor immediately after the 0-or-more <code>&gt;</code>, then nothing – no whitespace, no nothing – will be allowed after the <code>&lt;br&gt;</code> at the end of the line.  I hope that’s what you intended. If you really meant to match it, even when more stuff comes after the <code>&lt;br&gt;</code> on the same line, then you should use <code>.*&lt;p class="amigo"&gt;(?-s)(.*)&lt;br&gt;.*$</code></p>
</li>
<li>
<p dir="auto"><code>.*&lt;p</code>: just a note: if you happen to have the <code>☑ . matches newline</code> option checked in your <strong>Find</strong> window, then it will match from the beginning of the first line to the end of the last line with amigo-paragraph and <code>&lt;br&gt;</code>.  This can be seen with the example data here:</p>
<pre><code> &lt;p class="amigo"&gt;My mother is at home.&lt;br&gt;

 asfa

 asffa

 &lt;p class="amigo"&gt;My mother is at home.&lt;br&gt;

 asfa

 asffa

 &lt;p class="amigo"&gt;My mother is at home.&lt;p&gt;


 afasf

 &lt;p class="amigo"&gt;My mother is at home.&lt;br&gt;

 asfa

 asffa

 &lt;p class="amigo"&gt;My mother is at home.&lt;p&gt;

 asdas

 &lt;p class="amigo"&gt;My mother is at home.&lt;br&gt;

 asfa

 asffa
</code></pre>
<p dir="auto">… where  it would find 1 occurrence, when there are really four.  To fix this, move the <code>(?-s)</code> to the beginning of the pattern, instead of after the amigo-paragraph.</p>
</li>
</ol>
<p dir="auto">My recommended regular expression, which will allow text after the <code>&lt;br&gt;</code>, will not match <code>&lt;br</code>, and will keep the instances separate: <code>(?-s).*&lt;p class="amigo"&gt;(.*)&lt;br&gt;.*$</code></p>
]]></description><link>https://community.notepad-plus-plus.org/post/37731</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/37731</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Thu, 20 Dec 2018 17:06:20 GMT</pubDate></item><item><title><![CDATA[Reply to regex: Find all lines starting with a specific tag and ending with a different tag on Thu, 20 Dec 2018 17:02:26 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/7753">@Robin-Cruise</a></p>
<p dir="auto">The sequence (?s)(?-s) makes little sense in a regular exp.  I think what you really wanted was to drop both of those and change .* to .*?</p>
]]></description><link>https://community.notepad-plus-plus.org/post/37730</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/37730</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Thu, 20 Dec 2018 17:02:26 GMT</pubDate></item><item><title><![CDATA[Reply to regex: Find all lines starting with a specific tag and ending with a different tag on Thu, 20 Dec 2018 16:39:00 GMT]]></title><description><![CDATA[<p dir="auto">by the way, I just find the solution:</p>
<p dir="auto"><code>.*&lt;p class="amigo"&gt;(?s)(?-s)(.*)&lt;br&gt;*$</code></p>
<p dir="auto">see here:</p>
<p dir="auto"><a href="https://regex101.com/r/We7Afi/1" rel="nofollow ugc">https://regex101.com/r/We7Afi/1</a></p>
]]></description><link>https://community.notepad-plus-plus.org/post/37728</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/37728</guid><dc:creator><![CDATA[Robin Cruise]]></dc:creator><pubDate>Thu, 20 Dec 2018 16:39:00 GMT</pubDate></item><item><title><![CDATA[Reply to regex: Find all lines starting with a specific tag and ending with a different tag on Thu, 20 Dec 2018 16:32:32 GMT]]></title><description><![CDATA[<p dir="auto">you are not an expert :) did you try your solution before writing it here?</p>
<p dir="auto">no, it’s not about escape. My regex is almost good, but something else is missing :)</p>
]]></description><link>https://community.notepad-plus-plus.org/post/37727</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/37727</guid><dc:creator><![CDATA[Robin Cruise]]></dc:creator><pubDate>Thu, 20 Dec 2018 16:32:32 GMT</pubDate></item><item><title><![CDATA[Reply to regex: Find all lines starting with a specific tag and ending with a different tag on Thu, 20 Dec 2018 15:59:46 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/7753">@Robin-Cruise</a>   I’m no expert, but maybe you need to escape the <code>&lt;</code> and <code>&gt;</code> characters:<br />
<code>.*\&lt;p class="amigo"\&gt;(?s)(.*)\&lt;br\&gt;*$</code></p>
]]></description><link>https://community.notepad-plus-plus.org/post/37726</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/37726</guid><dc:creator><![CDATA[Jim Dailey]]></dc:creator><pubDate>Thu, 20 Dec 2018 15:59:46 GMT</pubDate></item></channel></rss>