Python-正则表达式学习内容
发布时间
阅读量:
阅读量
正则表达式在线生成
1.对应网络资源链接
http://www.baidu.com
^((https|http|ftp|rtsp|mms)?:\/\/)[^\s]
# ^: 以什么开头
# (https|http|ftp|rtsp|mms): 代表一个分组
# [https|http|ftp|rtsp|mms]: 代表一个字母
^:
如果没有在[]里面的时候, 代表以什么开头;
如果在[]里面的时候,代表除了...之外;
# \d ==== [0-9] === [0123456789]
import re
url = 'http://www.baidu.com'
pattern = r'^((https|http|ftp|rtsp|mms)?:\/\/)\S+'
# \ 标识符
# 进行分组的时候, findall方法只返回分组里面的内容;
# print(re.findall(pattern, url))
resObj = re.sea
全部评论 (0)
还没有任何评论哟~
