擅长:python、mysql、java
<p>像这样的方法有效:</p>
<pre><code>## pattern: Upercase, then anything that is not in (.!?), then one of them
>>> pat = re.compile(r'([A-Z][^\.!?]*[\.!?])', re.M)
>>> pat.findall('OMG is this a question ! Is this a sentence ? My. name is.')
['OMG is this a question !', 'Is this a sentence ?', 'My.']
</code></pre>
<p>注意<code>name is.</code>不在结果中,因为它不是以大写字母开头的。</p>
<p>您的问题来自于<code>^$</code>锚的使用,它们作用于整个文本。</p>