擅长:python、mysql、java
<p>使用</p>
<pre><code>match1 = reg1.search(s)
</code></pre>
<p>相反。<code>match</code>函数<em>只在字符串开头匹配。。。请参阅文档<a href="http://docs.python.org/library/re.html#search-vs-match" rel="nofollow noreferrer">here</a>:</p>
<blockquote>
<p>Python offers two different primitive operations based on regular expressions: <code>re.match()</code> checks for a match only at the beginning of the string, while <code>re.search()</code> checks for a match anywhere in the string (this is what Perl does by default).</p>
</blockquote>