asp教程 获取字符串中url地址函数
本文章提供了三款利用asp的正则获取字符串中url地址自定义函数哦三个方法的实现原理都是获取以http开的url地址哦
on error goto z
dim urlkeywwwname
url=requestservervariables("server_name")
if instr(url"")> then
key=split(url"")
wwwname=key()
wwwname=replace(wwwname"http://""")
end if
responsewrite(wwwname)
方法二
vbnet
public shared function isurl(byval strtmp as string) as boolean
on error goto z
dim objintpattern as new systemtextregularexpressionsregex( "^(http://|https教程://){}[azaz][azaz]+[azaz][azaz]{}[]*$")
return objintpatternismatch(strtmp)
z:
end function
private sub button_click(byval sender as systemobject byval e as systemeventargs) handles buttonclick
msgbox (isurl( "
方法三
dim objintpattern
isurl = false
set objintpattern = new regexp
objintpatternpattern = "^(http://|https://){}[azaz][azaz]+[azaz][azaz]{}[]*$"
objintpatternglobal = true
isurl = objintpatterntest(strtmp)
set objintpattern = nothing
z:
end function
private sub command_click()
msgbox isurl( "
end sub