擅长:python、mysql、java
<p>问题是match()用于匹配字符串的开头,而不是任何地方。
来自python文档:(<a href="https://docs.python.org/3/library/re.html#re.Pattern.match" rel="nofollow noreferrer">Python docs for match()</a>)</p>
<p>如果字符串的<strong>开头的</strong>有零个或多个字符与此正则表达式匹配,则返回相应的匹配对象</p>
<p>您应该改用search():
如果要在字符串中的任何位置找到匹配项,请改用search()</p>
<p><a href="https://docs.python.org/3/library/re.html#search-vs-match" rel="nofollow noreferrer">see also search() vs. match()</a></p>
<p>本部分:</p>
<pre><code>match = re.match(pattern, test, re.IGNORECASE)
</code></pre>
<p>必须是:</p>
^{pr2}$