网址示例:JS:如何获取网站名称?
let str = 'https://www.google.com.ua/images/branding/product/ico/googleg_lodp.ico'
let str1 = 'https://www.google.com/images/branding/product/ico/googleg_lodp.ico'
let str2 = 'https://books.google.com.ua/images/branding/product/ico/googleg_lodp.ico'
如何从这样的网址,只得到网站的名称?只有这个词 - 谷歌。
你是什么意思的网站名称?可以说str2你期待什么? –
Sarath Kumar,这个答案不适合。没有考虑到子域和二级域。 – VINET
那么,你期待什么样的str2? –