函数功能从提交的URL中提取顶级域名
,失败返回空
,注意要把可用的后缀全写到domext变量中
。
function durlck(url)
domext="com|net|org|cn|co.kr|com.cn"
durlck="" : url=lcase(url)
if url="" or len(url)=0 then exit function
url=replace(replace(url,"
http://",""),"https://","")
s1=instr(url,":")-1 '过滤掉端口
if s1 < 0 then s1=instr(url,"/")-1 '过滤掉/后面的字符
if s1 > 0 then url=left(url,s1)
Set re = new RegExp
re.IgnoreCase = True : re.global = True
re.Pattern = "([a-z0-9-]){1,63}\.(" & domext & ")(\:\d+)?$"
Set Matches = re.Execute(url)
durlck = Matches(0)
set re=nothing
end function