擅长:python、mysql、java
<p>正则表达式中的<code>[^(0x)]</code>匹配任何不是<code>(</code>、<code>0</code>、<code>x</code>、<code>)</code>的字符。你知道吗</p>
<p>使用负向后看:</p>
<pre><code>>>> re.findall(r'(?<!0x)\d+\b', '0 0x111 50505 20201 0012')
['0', '11', '50505', '20201', '0012']
</code></pre>
<p>从<a href="http://docs.python.org/2/library/re.html" rel="nofollow">http://docs.python.org/2/library/re.html</a></p>
<blockquote>
<p>(?<!...)</p>
<p>Matches if the current position in the string is not preceded by a
match for .... This is called a negative lookbehind assertion. Similar
to positive lookbehind assertions, the contained pattern must only
match strings of some fixed length. Patterns which start with negative
lookbehind assertions may match at the beginning of the string being
searched.</p>
</blockquote>
<hr/>
<p><strong>更新</p>
<p>使用以下正则表达式:</p>
<pre><code>>>> re.findall(r'\b\d+\b', '0 0x111 50505 20201 0012')
['0', '50505', '20201', '0012']
</code></pre>