[python3 - package] re 正则表达式

1. 官方文档

https://docs.python.org/3/howto/regex.html

2. 重复次数

* {0,}
+ {1,}
{0,1}

 

 

 

3. 实例

#网站域名匹配
url = 'http://www.mafengwo.cn/gonglve/'
p = re.compile('https?://www([^/][\S.])+/?')
print(p.match(url).group()) #http://www.mafengwo.cn/

 

posted @ 2018-02-22 22:24  break大蜗牛  阅读(135)  评论(0编辑  收藏  举报