正则表达式匹配域名

时间:2020-04-08 00:03:49

标签: python regex

2 个答案:

答案 0 :(得分:0)

(https?:\/\/)([^\/]+)\/

Example matches

答案 1 :(得分:0)

您也可以在库中使用内置的正则表达式,而不用编写自己的正则表达式。

Python3

from urllib.parse import urlparse
urlparse('https://www.regexpal.com/?fam=93928').netloc

输出:

'www.regexpal.com'