擅长:python、mysql、java
<p>默认情况下,<code>findall</code>不产生重叠匹配。但是,此表达式确实:</p>
<pre><code>>>> re.findall(r'(?=(\w\w))', 'hello')
['he', 'el', 'll', 'lo']
</code></pre>
<p>这里<code>(?=...)</code>是一个<a href="http://docs.python.org/library/re.html" rel="noreferrer"><strong>lookahead assertion</strong></a>:</p>
<blockquote>
<p><code>(?=...)</code> matches if <code>...</code> matches next, but doesn’t consume any of the
string. This is called a lookahead assertion. For example,
<code>Isaac (?=Asimov)</code> will match <code>'Isaac '</code> only if it’s followed by <code>'Asimov'</code>.</p>
</blockquote>