擅长:python、mysql、java
<blockquote>
<p>I thought that by putting the \s character in parentheses, that it would make a capture group, and only that space would be replaced.</p>
</blockquote>
<p>这不是捕获组的工作方式。所有匹配的内容仍然会被替换,但是对于捕获组,您可以引用替换中匹配的部分。在</p>
<p>我要改两行你的剧本:</p>
<pre><code>pattern = '(?i)([a-z]*[\u4300-\u9fff]+)\s([a-z]*[\u4300-\u9fff]+)'
</code></pre>
<p>以及</p>
^{pr2}$