【发布时间】:2012-12-06 06:31:31
【问题描述】:
假设我有一个字符串
This is a good doll http://www.google.com/a/bs/jdd/etc/etc/a.py
我想得到这样的东西
This is a good doll www.google.com
我在 python 中尝试了print re.sub(r'(http://|https://)',"",a)) 函数,但我只能从中删除http:// 部分。关于如何在 python 2.7 中实现这一点的任何想法
【问题讨论】:
-
您可能想要添加您的正则表达式尝试
-
使用urlparse库解析url并获取主机名。
标签: python regex python-2.7