我的网址看起来像这样
https://www.regexpal.com/?fam=93928
https://tekno.tempo.co/read/1329116/harimau-sumatera-ditemui-di-hutan-produksi-tapanuli-selatan
http://stackoverflow.com/posts/61091339/edit
我该如何在正则表达式中匹配它们?
inet.detik.com
www.regexpal.com
tekno.tempo.co
stackoverflow.com
答案 0 :(得分:0)
(https?:\/\/)([^\/]+)\/
答案 1 :(得分:0)
您也可以在库中使用内置的正则表达式,而不用编写自己的正则表达式。
在 Python3
from urllib.parse import urlparse
urlparse('https://www.regexpal.com/?fam=93928').netloc
输出:
'www.regexpal.com'