【发布时间】:2018-09-11 02:34:31
【问题描述】:
我想删除 URL/电子邮件地址中的所有空格。地址位于“普通”字符串中,例如:"Today the weather is fine. Tomorrow, we'll see. More information: www.weather .com or info @weather.com"
我正在寻找一个好的正则表达式(使用 Python 的 re 模块),但我的版本无法处理所有情况
re.sub(u'(www)([ .])([a-zA-Z\-]+)([ .])([a-z]+)', '\\1.\\3.\\5')
【问题讨论】:
-
预期输出是什么?
-
你不能用
replace吗?"https://www . some-example.c o m".replace(' ', '')
标签: python regex removing-whitespace