有这样一个字符串:
<p>Millions of people watch TV.</p><br/>https://sites.google.com/aaa-net.bb.cc/be-do-have/%E3%83%9B%E3%83%BC%E3%83%A0<br/><p>Good boy!</p><br/>
我要删除内容:
https://sites.google.com/aaa-net.bb.cc/be-do-have/%E3%83%9B%E3%83%BC%E3%83%A0
保持:
<p>Millions of people watch TV.</p><br/><br/><p>Good boy!</p><br/>
我的代码:
mystring = '<p>Millions of people watch TV.</p><br/>https://sites.google.com/aaa-net.bb.cc/be-do-have/%E3%83%9B%E3%83%BC%E3%83%A0<br/><p>Good boy!</p><br/>'
怎么做?你知道吗
您可以从regex模块使用
re.sub
:输出:
可以使用regex replace执行此操作:
查找:
<br/>https?://[^<]*</br>
替换:
<br/></br>
相关问题 更多 >
编程相关推荐