[英]Python regex to remove punctuation except from URLs and decimal numbers
[英]Python - Remove URLs from text with regex
我的文字中包含以下网址:
<https://buy.itunes.apple.com/WebObjects/MZFinance.woa/wa/reportAProblem?p
=22000073760328&o=i>
我使用以下模式尝试删除它们:
re.sub(r'\<http.+?\>', '', plain, re.S)
但这并不能全部解决,例如,这一点不会被删除:
<http://ax.phobos.apple.com.edgesuite.net/email/images_shared/spacer_99999\r\n9.gif>
像这样尝试
p=re.compile(r'\<http.+?\>', re.DOTALL)
re.sub(p, '', plain)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.