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.
import re
st="""dddabc
d
e
xxxx
123
345
"""
rep="abcde"
print(re.sub(r'\n?'.join(rep),r'',st))
使用正则表达式^{}
输出
使用regex如下:
相关问题 更多 >
编程相关推荐