Python 使用正則表達式匹配URL網址

使用正則表達式匹配以 .com 或 .cn 爲域名後綴的URL地址html In [1]: import re In [2]: str = "http://www.baidu.com/" In [3]: regular = re.compile(r'[a-zA-Z]+://[^\s]*[.com|.cn]') In [4]: re.findall(regular, str)
相關文章
相關標籤/搜索