asp 获取字符串中url地址函数

2015-08-12 16:03:39来源:作者:人点击

asp教程 获取字符串中url地址函数
本文章提供了三款利用asp的正则获取字符串中url地址自定义函数哦,三个方法的实现原理都是获取以http开的url地址哦。
on error goto z

dim url,key,wwwname
url=request.servervariables("server_name")
if instr(url,".")>0 then
key=split(url,".")
wwwname=key(0)
wwwname=replace(wwwname,"http://","")
end if
response.write(wwwname)

 方法二

'vb.net:
public shared function isurl(byval strtmp as string) as boolean
on error goto z
dim objintpattern as new system.text.regularexpressions.regex( "^(http://|https教程://){0,1}[a-za-z0-9][a-za-z0-9-.]+[a-za-z0-9].[a-za-z]{2,}[43-176]*$")
return objintpattern.ismatch(strtmp)
z:
end function

private sub button1_click(byval sender as system.object, byval e as system.eventargs) handles button1.click
msgbox (isurl( "http://www.sohu.com"))
方法三

dim objintpattern
isurl = false
set objintpattern = new regexp
objintpattern.pattern = "^(http://|https://){0,1}[a-za-z0-9][a-za-z0-9-.]+[a-za-z0-9].[a-za-z]{2,}[43-176]*$"
objintpattern.global = true
isurl = objintpattern.test(strtmp)
set objintpattern = nothing
z:
end function

private sub command1_click()
msgbox isurl( "http://www.sohu.com")
end sub

最新文章

123

最新摄影

微信扫一扫

第七城市微信公众平台