擅长:python、mysql、java
<p>您必须使用否定字符类来不匹配<code>,</code>,而是匹配任何字符。因为正则表达式中的<code>.*</code>是贪婪的,在找到匹配之前,它不会吃掉任何字符,或者使<code>.*</code>像<code>.*?</code>一样不贪婪</p>
<pre><code>found_group = re.search('([^,]*)in ([^,]*),(.*)', "In North Dighton, there's a Flash Flood Watch in effect until Wednesday, July 12, 9:00 PM.", re.IGNORECASE)
fround_group.group(2)
</code></pre>
<p><a href="https://regex101.com/r/QheZDn/1" rel="nofollow noreferrer">Demo 1</a>
<a href="https://regex101.com/r/QheZDn/2" rel="nofollow noreferrer">Demo 2</a></p>