擅长:python、mysql、java
<p>从<a href="https://docs.python.org/2/library/re.html#re.sub" rel="nofollow">docs</a>:</p>
<blockquote>
<p>The backreference <code>\g<0></code> substitutes in the entire substring matched by the RE.</p>
</blockquote>
<p>示例:</p>
<pre><code>>>> print re.sub("[_%^$]", r"\\\g<0>", line)
\_\_\^\^\^\%\%\%\_\_FooBar
</code></pre>