擅长:python、mysql、java
<p>你可以用</p>
<pre><code>(?=[b-df-hj-np-tv-xz])(.)(?!\1)(?<!\1\1)
</code></pre>
<p>展现为</p>
^{pr2}$
<p>但遗憾的是,<a href="https://docs.python.org/dev/library/re.html" rel="nofollow">^{<cd1>}</a>中不允许最后一行,因为lookbehind必须有固定的长度。但是<a href="https://pypi.python.org/pypi/regex" rel="nofollow">^{<cd2>}</a>模块¹支持它</p>
<pre><code>In [1]: import regex
In [2]: s=r'(?=[b-df-hj-np-tv-xz])(.)(?!\1)(?<!\1\1)'
In [3]: regex.findall(s, 'happy')
Out[3]: ['h']
In [4]: regex.findall(s, 'accomplished')
Out[4]: ['m', 'p', 'l', 's', 'h', 'd']
</code></pre>
<hr/>
<p>根据cheeseshop的描述,“最终将取代Python当前的re-module实现”。在</p>