ASP正則表達式解析出網址中的域名部分
<%
Function getDomain(domain)
Dim re,ReturnStr,Matches
Set re=new RegExp
re.IgnoreCase =True
re.Global=True
re.Pattern = "(/w+/.(com.cn|net.cn|com|cn|net|org))"
Set Matches = re.Execute(domain)
ReturnStr = ""
For Each Match in Matches
ReturnStr = Match.Value
Exit for
Next
getDomain = ReturnStr
Set re=Nothing
End Function
response.write getDomain("http://www.bak.sina.com.cn/abc.htmlhttp://www.bak.baidu.com.cn/abc.html")
%>
Function getDomain(domain)
Dim re,ReturnStr,Matches
Set re=new RegExp
re.IgnoreCase =True
re.Global=True
re.Pattern = "(/w+/.(com.cn|net.cn|com|cn|net|org))"
Set Matches = re.Execute(domain)
ReturnStr = ""
For Each Match in Matches
ReturnStr = Match.Value
Exit for
Next
getDomain = ReturnStr
Set re=Nothing
End Function
response.write getDomain("http://www.bak.sina.com.cn/abc.htmlhttp://www.bak.baidu.com.cn/abc.html")
%>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.