Python 使用正则表达式匹配URL网址

1  import re
2  str = "http://www.baidu.com/"
3  regular = re.compile(r'[a-zA-Z]+://[^\s]*[.com|.cn]')
4  re.findall(regular, str)                             
 ['http://www.baidu.com']

 

posted @ 2020-04-21 16:58  燕十三丶  阅读(5246)  评论(0编辑  收藏  举报
AmazingCounters.com