擅长:python、mysql、java
<p><strong>编辑</strong>要将多个连续换行符<code>(\n)</code>替换为<code>____</code>,应该这样做:</p>
<pre><code>>>> import re
>>> i = "(2 months)\n\nML"
>>> re.sub(r'(\n+)(?=[A-Z])', r'____', i)
'(2 months)____ML'
</code></pre>
<p><code>(?=[A-Z])</code>是断言“换行符后跟大写字母”。<a href="https://regex101.com/r/yO8qT2/1" rel="nofollow">REGEX DEMO</a>。在</p>