社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
私信  •  关注

Allan The fourth bird

Allan The fourth bird 最近创建的主题
Allan The fourth bird 最近回复了
6 年前
回复了 Allan The fourth bird 创建的主题 » python中url的正则表达式

URL以http开头,并且在您的模式中匹配 [s*] 两者都匹配 s * character class .

我想你在找

https?:[a-zA-Z0-9_.+-/#~]+ 

Regex demo γ Python demo

import re
regex = r"https?:[a-zA-Z0-9_.+-/#~]+ "
article = "眼影盤長這樣 http://i.imgur.com/uxvRo3h.jpg 說真的 很不好拍"
result = re.sub(regex, "", article)
print(result)

结果

眼影盤長這樣 說真的 很不好拍

一个较短的表达式,其匹配范围稍宽,也可以是非空白的1+倍。 \S+ char后跟0+乘以空格,以匹配原始模式中的尾随空格。

\bhttps?:\S+ *

Regex demo