擅长:python、mysql、java
<p>使用正则表达式<a href="https://docs.python.org/2/library/re.html#re.sub" rel="nofollow noreferrer">^{<cd1>}</a></p>
<blockquote>
<p>Return the string obtained by replacing the leftmost non-overlapping
occurrences of pattern in string by the replacement repl. If the
pattern isn’t found, string is returned unchanged. repl can be a
string or a function; if it is a string, any backslash escapes in it
are processed.</p>
</blockquote>
<pre><code>import re
st="""dddabc
d
e
xxxx
123
345
"""
rep="abcde"
print(re.sub(r'\n?'.join(rep),r'',st))
</code></pre>
<p>输出</p>
<pre><code>ddd
xxxx
123
345
</code></pre>