擅长:python、mysql、java
<p>您可以将以下正则表达式与捕获组和反向引用一起使用:</p>
<pre><code>#([0-9A-Fa-f]{2})\1{2}
</code></pre>
<p>参见<a href="https://regex101.com/r/gvNqAv/1" rel="nofollow noreferrer">regex demo</a></p>
<p><strong>详细信息</strong></p>
<ul>
<li><code>#</code>-a<code>#</code></li>
<li><code>([0-9A-Fa-f]{2})</code>-第1组:2个十六进制字符</li>
<li><code>\1{2}</code>-2连续出现与第1组相同的值。在</li>
</ul>
<p>注意:为了使<code>\1</code>backreference以不区分大小写的方式匹配第1组的内容,需要使用不区分大小写的标志。请记住,我们需要使用原始字符串文本来定义正则表达式,以避免跳过反向引用。在</p>
<p>请参见<a href="https://ideone.com/52hYR1" rel="nofollow noreferrer">Python demo</a>:</p>
^{pr2}$
<p>结果:</p>
^{3}$