1. 程式人生 > >[python3 - package] re 正則表達式

[python3 - package] re 正則表達式

www. log regex height 正則表達式 table div idt pac

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/

[python3 - package] re 正則表達式