教程集 www.jiaochengji.com
教程集 >  脚本编程  >  Asp.net  >  正文 asp 获取字符串中url地址函数

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

发布时间:2016-09-26   编辑:jiaochengji.com
教程集为您提供asp 获取字符串中url地址函数等资源,欢迎您收藏本站,我们将为您提供最新的asp 获取字符串中url地址函数资源
本文章提供了三款利用asp的正则获取字符串中url地址自定义函数哦,三个方法的实现原理都是获取以http开的url地址哦。

on error goto z
'

<blockquote>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) </blockquote>

'方法二

<blockquote>

'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,}[#-~]*$")
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"))

</blockquote>

'方法三

<blockquote>

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,}[#-~]*$"
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

</blockquote>

您可能感兴趣的文章:
asp 获取字符串中url地址函数
php 获取网站地址的函数代码
php字符串操作函数入门篇
Javascript获得当前网页详细地址的代码
JavaScript分段获取URL的方法介绍
PHP提取字符串中的图片地址2种方法
ASP 获取腾讯IP地址的接口程序代码
javascript获取地址栏参数的二种方法
asp 获取地址栏参数代码
PHP字符串函数与使用分析

[关闭]
~ ~