擅长:python、mysql、java
<p><a href="https://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454">You shouldn't parse xml with regex</a>。也就是说,regex的greedyness让你,<code>[\w\W]*</code>几乎匹配任何东西,所以它会吃掉第一个表达式。你知道吗</p>
<p>添加一个非贪婪的<code>?</code>标记(<code>[\w\W]*?</code>)修复了这个问题。在小组里加一个也没什么坏处。我已经用<code>.*?</code>替换了<code>[\w\W]*?</code>,因为它更简单、更等价。你知道吗</p>
<pre><code>regex = re.compile('<a class="biz-name.*?<span>(.*?)</span>')
</code></pre>
<p>在<a href="https://regex101.com/r/mTaPTE/1" rel="nofollow noreferrer">regex101</a>上看到这个。你知道吗</p>