龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > web编程 > asp编程 >

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

时间:2012-12-31 22:56来源:未知 作者:admin 点击:
分享到:
asp 获取字符串中url地址函数'本文章提供了三款利用asp的正则获取字符串中url地址自定义函数哦,三个方法的实现原理都是获取以http开的url地址哦。 asp教程 获取字符串中url地址函数 '本
asp 获取字符串中url地址函数 '本文章提供了三款利用asp的正则获取字符串中url地址自定义函数哦,三个方法的实现原理都是获取以http开的url地址哦。

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


精彩图集

赞助商链接