【发布时间】:2021-05-13 20:32:43
【问题描述】:
我正在尝试替换长字符串中的几个 url。
这里是一个示例:
s = 'https://www.yellowpages.ca/bus/Alberta/Edmonton/MNS-Enterprise-\nLtd/8114324.html, https://411.ca/business/profile/13300641'
由于 url 中的换行符,匹配将始终在 \n 处停止。
我试过了
re.sub(r'(https?://[\S]*)', 'website__', s, re.DOTALL)
但结果在\n 中断
'website__\nLtd/8114324.html, website__'
【问题讨论】: