擅长:python、mysql、java
<p><code>.*</code>是一个贪婪的<em>,与你想要的<code>:end</code>边界相匹配。将所有<code>.*</code>替换为<em>lazy</em><code>.*?</code>。在</p>
<pre><code>>>> s = """...', 'begin:32,12:1:2005-10-30 T 10:45:end', 'begin:33,13:2:2006-11-31 T 11:46:end', '... <div dir="ltr">begin:32,12:1:2005-10-30 T 10:45:end<br>begin:33,13:2:2006-11-31 T 11:46:end<br>..."""
>>> re.findall("begin:(.*?),(.*?):(.*?):(.*?:.*?):end", s)
[('32', '12', '1', '2005-10-30 T 10:45'), ('33', '13', '2', '2006-11-31 T 11:46'),
('32', '12', '1', '2005-10-30 T 10:45'), ('33', '13', '2', '2006-11-31 T 11:46')]
</code></pre>
<p>使用修改后的模式,强制在匹配的开始/结尾出现单引号:</p>
^{pr2}$