擅长:python、mysql、java
<p>替换时使用排除,如下所示:</p>
<pre><code>import re
mytext = "This is AVGs and (NMN) and most importantly GFD"
mytext= re.sub(r"([A-Z]{2,})", "\\1_ABB", mytext)
print(mytext)
</code></pre>
<p><strong>输出:</strong></p>
<p><code>This is AVGs_ABB and (NMN_ABB) and most importantly GFD_ABB</code></p>