擅长:python、mysql、java
<p>作为Python的<code>re</code>模块的替代,您可以使用<a href="https://pypi.python.org/pypi/regex" rel="nofollow">^{<cd2>}</a>库显式地执行此操作,该库支持字符类的set操作:</p>
<blockquote>
<p>The operators, in order of increasing precedence, are:</p>
<p><code>||</code> for union (<code>“x||y”</code> means “x or y”)</p>
<p><code>~~</code> (double tilde) for symmetric difference (<code>“x~~y”</code> means “x or y, but not > both”)</p>
<p><code>&&</code> for intersection (<code>“x&&y”</code> means “x and y”)</p>
<p><code> </code> (double dash) for difference (<code>“x–y”</code> means “x but not y”)</p>
</blockquote>
<p>为了只匹配辅音,您的正则表达式可以是:</p>
<pre><code>>>> regex.findall('[[a-z]&&[^aeiou]]+', 'abcde', regex.VERSION1)
['bcd']
</code></pre>
<p>或等效使用设置差:</p>
^{pr2}$