<?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[Find Duplicate HTML Tags with Regex]]></title><description><![CDATA[<p dir="auto">I’m trying to write a regex to find duplicate HTML tag ID’s. Here’s the expression I’m working on. It works  <strong>only if the HTML tags are on the same line</strong>.</p>
<pre><code>((id=".+").+\g-1)
</code></pre>
<p dir="auto">Here’s the HTML I’m running it against:</p>
<pre><code>&lt;ol&gt;
&lt;li id="duplicate-id"&gt;Testing &lt;span id="duplicate-id"&gt;regex&lt;/span&gt; to find duplicate HTML tag ID’s.&lt;/li&gt;
&lt;li&gt;It finds the duplicates in the next two list elements (even though they’re on the same line)&lt;/li&gt;
&lt;li&gt;Duplicate tags in two elements but &lt;em&gt;on one line&lt;/em&gt;. First duplicate &lt;span id="another-duplicate"&gt;here&lt;/span&gt;.&lt;/li&gt;&lt;li&gt;Then a second one &lt;span id="another-duplicate"&gt;here&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;It does &lt;em&gt;not&lt;/em&gt; find the duplicate ID’s in the &lt;em&gt;next&lt;/em&gt; two elements &lt;em&gt;on separate lines&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;First duplicate &lt;span id="another-duplicate"&gt;here&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;And, after a line break, a &lt;span id="another-duplicate"&gt;second&lt;/span&gt; duplicate&lt;/li&gt;
&lt;/ol&gt;

</code></pre>
<p dir="auto">Notes:</p>
<ul>
<li>
<p dir="auto">I include the outer enclosing parentheses because  I want to append this to a larger regex once it works.</p>
</li>
<li>
<p dir="auto">I need  to check over 10,000 files, so an on line HTML checker impractical.</p>
</li>
</ul>
<p dir="auto">The Boost documentation says the dot character (just before <strong>\g</strong> in the above regex) includes line breaks by default. But I seem to be getting the <strong>opposite</strong> behavior.</p>
<p dir="auto">I’m using Notepad++ 7.8.2 (64-bit) on Windows 10.</p>
<p dir="auto">Can anyone see what I’m doing wrong?</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/18818/find-duplicate-html-tags-with-regex</link><generator>RSS for Node</generator><lastBuildDate>Tue, 06 Oct 2026 09:06:48 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/18818.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 25 Jan 2020 19:58:27 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Find Duplicate HTML Tags with Regex on Fri, 31 Jan 2020 01:45:41 GMT]]></title><description><![CDATA[<p dir="auto">Hi, <a class="plugin-mentions-user plugin-mentions-a" href="/user/sylvester-bullitt" aria-label="Profile: sylvester-bullitt">@<bdi>sylvester-bullitt</bdi></a>, <a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: alan-kilborn">@<bdi>alan-kilborn</bdi></a>, <a class="plugin-mentions-user plugin-mentions-a" href="/user/peterjones" aria-label="Profile: peterjones">@<bdi>peterjones</bdi></a> and <strong>All</strong>,</p>
<p dir="auto">Some observations about <strong>in-line</strong> modifiers :</p>
<p dir="auto">Let’s consider the text :</p>
<pre><code class="language-diff">1 abc
2 abC
3 aBc
4 aBC
5 Abc
6 AbC
7 ABc
8 ABC
</code></pre>
<ul>
<li>
<p dir="auto">The regex <strong><code>(?-i)a((?i)b)c</code></strong> matches lines <strong><code>1</code></strong> and <strong><code>3</code></strong> and the <strong>group <code>1</code></strong> contains the letter <strong>b</strong> or <strong>B</strong></p>
</li>
<li>
<p dir="auto">Using a <strong>non-capturing</strong> group, the <strong>full</strong> syntax of the regex becomes <strong><code>(?-i)a(?:(?i)b)c</code></strong> and matches the <strong>same</strong> lines <strong><code>1</code></strong> and <strong><code>3</code></strong> but, this time, <strong>no</strong> group is <strong>defined</strong></p>
</li>
<li>
<p dir="auto">As a convenient <strong>shorthand</strong>, in case of a <strong>non-capturing</strong> group, the option may appear between the <strong>question mark</strong> and the <strong>colon</strong>, giving the alternate syntax <strong><code>(?-i)a(?i:b)c</code></strong>, which produces the same results as the <strong>former</strong> regex</p>
</li>
<li>
<p dir="auto">Note that, because options are <strong>not</strong> reset until the <strong>end</strong> of a subpattern, if that subpattern contains <strong>alternatives</strong>, an option setting in <strong>one</strong> branch does affect all the <strong>subsequent</strong> branches !</p>
</li>
</ul>
<p dir="auto">So, assuming the text :</p>
<pre><code class="language-diff">1 ab
2 aB
3 Ab
4 AB
5 cd
6 cD
7 Cd
8 CD
</code></pre>
<ul>
<li>The regex <strong><code>((?-i)ab|CD)</code></strong>, with <strong>group<code>1</code></strong> and the regex <strong><code>(?-i:ab|CD)</code></strong>, with a <strong>non-capturing</strong> group, match, <strong>both</strong>, lines <strong><code>1</code></strong> and <strong><code>8</code></strong>, <strong>only</strong></li>
</ul>
<hr />
<p dir="auto">REMARK :</p>
<ul>
<li>
<p dir="auto">Note that the <strong>previous</strong> rule is always <strong>valid</strong> if, when choosing between the different <strong>alternatives</strong>, the regex engine is <strong>not</strong> aware of a <strong>later</strong> option. For instance, let’s consider the regex <strong><code>(?-i)(a(?i)b|cd)</code></strong></p>
</li>
<li>
<p dir="auto">In this regex, due to the <strong>initial</strong> <strong><code>(?-i)</code></strong> modifier, the search should be done in a <strong>sensitive</strong> way, except for the part <strong><code>(?i)b</code></strong>, which should match letter <strong>b</strong> or <strong>B</strong>. However, this regex matches the lines <strong><code>1</code></strong> and <strong><code>2</code></strong> and lines from <strong><code>5</code></strong> to <strong><code>8</code></strong>, in the <strong>above</strong> text !</p>
</li>
<li>
<p dir="auto">For instance, when the regex engine is located, right before the <strong>first</strong> letter of line <strong><code>8</code></strong>, and choose the <strong>second</strong> alternative, in order to process <strong><code>c</code></strong>, rather than <strong><code>a</code></strong>, it does <strong>not</strong> know about the <strong>caseless</strong> option, applied to letter <strong>b</strong>. Still, it does match the <strong>uppercase</strong> letter <strong>C</strong> because the <strong><code>(?i)</code></strong> modifier is <strong>carried</strong> on into the <strong><code>cd</code></strong> alternative, as well !</p>
</li>
</ul>
<p dir="auto">Best Regards,</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/50195</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/50195</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Fri, 31 Jan 2020 01:45:41 GMT</pubDate></item><item><title><![CDATA[Reply to Find Duplicate HTML Tags with Regex on Thu, 30 Jan 2020 21:13:22 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: Alan-Kilborn">@<bdi>Alan-Kilborn</bdi></a> said in <a href="/post/50192">Find Duplicate HTML Tags with Regex</a>:</p>
<blockquote>
<p dir="auto">Apparently there was no “group #3” with the first search syntax.</p>
</blockquote>
<p dir="auto">Yes.  As it says in <a href="https://npp-user-manual.org/docs/searching/#readability-enhancements" rel="nofollow ugc">Readability Enhancements</a>, “<code>(?:subset)</code> ⇒ A grouping construct for the subset expression that doesn’t count as a subexpression (doesn’t get numbered or named)”.  That was meant to apply to the <code>(?enable-disable:subset)</code> as well, but maybe it’s not clear enough.  I’ll think about adding in something more explicit either in that paragraph, or in the <a href="https://npp-user-manual.org/docs/searching/#search-modifiers" rel="nofollow ugc">Search Modifiers</a> below (or both).</p>
]]></description><link>https://community.notepad-plus-plus.org/post/50193</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/50193</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Thu, 30 Jan 2020 21:13:22 GMT</pubDate></item><item><title><![CDATA[Reply to Find Duplicate HTML Tags with Regex on Thu, 30 Jan 2020 21:01:20 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/peterjones" aria-label="Profile: PeterJones">@<bdi>PeterJones</bdi></a></p>
<p dir="auto">So with my newfound knowledge based on your post, I tried this search regex to solve a realworld problem:</p>
<p dir="auto"><code>(?-i)(XXX)|(Xxx)|(?i:YYY)</code></p>
<p dir="auto">The intent was to match XXX or Xxx exactly or to match any case of YYY. My replace string was:</p>
<p dir="auto"><code>(?1QQ)(?2ZZ)(?3AA)</code></p>
<p dir="auto">and I think that is where the trouble lies. Changing the search expression slightly to:</p>
<p dir="auto"><code>(?-i)(XXX)|(Xxx)|((?i)YYY)</code></p>
<p dir="auto">made it work as intended.  Apparently there was no “group #3” with the first search syntax.</p>
<p dir="auto">It appears that if you use the <code>(?_:____)</code> type of syntax, a capturing group is not formed.  Hindsight says it makes sense, but it was a tad bit unexpected, especially since I had the <code>(YYY)</code> part at first, successfully capturing, and just slipped in the <code>?i:</code> bit later when I determined I needed to ignore case.  That’s when the regex gods said “Gotcha, padawan!”</p>
]]></description><link>https://community.notepad-plus-plus.org/post/50192</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/50192</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Thu, 30 Jan 2020 21:01:20 GMT</pubDate></item><item><title><![CDATA[Reply to Find Duplicate HTML Tags with Regex on Sun, 26 Jan 2020 20:07:03 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: Alan-Kilborn">@<bdi>Alan-Kilborn</bdi></a> said in <a href="/post/50099">Find Duplicate HTML Tags with Regex</a>:</p>
<blockquote>
<p dir="auto">You can turn it on and off as needed</p>
</blockquote>
<p dir="auto">You can also turn it on for just the given subexpression using the colon syntax:</p>
<pre><code>(?-s:subquery1)|(?s:subquery2)
</code></pre>
<p dir="auto"><a href="https://npp-user-manual.org/docs/searching/#search-modifiers" rel="nofollow ugc">https://npp-user-manual.org/docs/searching/#search-modifiers</a></p>
]]></description><link>https://community.notepad-plus-plus.org/post/50100</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/50100</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Sun, 26 Jan 2020 20:07:03 GMT</pubDate></item><item><title><![CDATA[Reply to Find Duplicate HTML Tags with Regex on Sun, 26 Jan 2020 19:39:26 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sylvester-bullitt" aria-label="Profile: Sylvester-Bullitt">@<bdi>Sylvester-Bullitt</bdi></a></p>
<p dir="auto">You can turn it on and off as needed.  Example:</p>
<p dir="auto"><code>(?-s)blahblahblah(?s)blahblah(?-s)blahblahblah</code></p>
<p dir="auto">or</p>
<p dir="auto"><code>(?s)blahblahblah(?-s)blahblah(?s)blahblahblah</code></p>
<p dir="auto">where <code>blah</code> is an intermediate regular expression sequence.</p>
<p dir="auto">In this case, only what’s between <code>(?s)</code> and <code>(?-s)</code> in the first case is going to be subject to the <code>.</code> character matching linebreaks.  For the second case, it would be everywhere <em>except</em> in the middle.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/50099</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/50099</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Sun, 26 Jan 2020 19:39:26 GMT</pubDate></item><item><title><![CDATA[Reply to Find Duplicate HTML Tags with Regex on Sun, 26 Jan 2020 19:07:11 GMT]]></title><description><![CDATA[<p dir="auto">Thanks for replying, Alan. I can’t turn use the “matches newline” check box in my scenario, because this is one of many queries combined into a large consolidated query, and it would cause the other subqueries to fail.</p>
<p dir="auto">I tried the (?s) option, but it it seemed to have no effect. I must have been using it wrong. If I have a one large query with a lot of subqueries, does it have to go at the start of the entire query, or can it be used at the beginning of a subquery? That it is, would it work with an overall query sructured like this?</p>
<pre><code>(subquery1)|(?s)subquery2)|(subquery3) etc.
</code></pre>
]]></description><link>https://community.notepad-plus-plus.org/post/50097</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/50097</guid><dc:creator><![CDATA[Sylvester Bullitt]]></dc:creator><pubDate>Sun, 26 Jan 2020 19:07:11 GMT</pubDate></item><item><title><![CDATA[Reply to Find Duplicate HTML Tags with Regex on Sat, 25 Jan 2020 21:47:30 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sylvester-bullitt" aria-label="Profile: Sylvester-Bullitt">@<bdi>Sylvester-Bullitt</bdi></a></p>
<p dir="auto">Not looking too hard at your specific problem, but just at the “.” and “line breaks” part.</p>
<p dir="auto">It is going to depend upon the <code>. matches newline</code> box setting.  If unticked, it won’t match linebreaks.  If ticked, it will.</p>
<p dir="auto">Alternatively, you can ignore that checkbox completely and include <code>(?s)</code> at the start of your regex to allow linebreak matching, and <code>(?-s)</code> to disallow it.</p>
<p dir="auto">Hope this helps…</p>
]]></description><link>https://community.notepad-plus-plus.org/post/50091</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/50091</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Sat, 25 Jan 2020 21:47:30 GMT</pubDate></item></channel></rss>