擅长:python、mysql、java
<p>我建议你</p>
<pre><code>r = re.compile(r"\B'\w+'\B")
apos = r.findall("This hasn't been much that much of a twist and turn's to 'Tom','Harry' and u know who..yes its 'rock'")
</code></pre>
<p>结果:</p>
<pre><code>>>> apos
["'Tom'", "'Harry'", "'rock'"]
</code></pre>
<p>“负单词边界”(<code>\B</code>)阻止了类似于<code>Rock'n'Roll</code>的单词中的<code>'n'</code>的匹配。</p>
<p><strong>说明:</strong></p>
<pre><code>\B # make sure that we're not at a word boundary
' # match a quote
\w+ # match one or more alphanumeric characters
' # match a quote
\B # make sure that we're not at a word boundary
</code></pre>