擅长:python、mysql、java
<p>使用<code>re.search()</code>函数:</p>
<pre><code>import re
s = '#aAAaaA'
match = re.search(r'#([0-9a-z]{2})\1\1', s, re.I)
result = match if not match else match.group()
print(result)
</code></pre>
<hr/>
<ul>
<li><p><code>\1</code>-指向第一个带圆括号的组<code>(...)</code></p></li>
<li><p><code>re.I</code>-<em>IGNORECASE</em>regex标志</p></li>
</ul>