当前位置: 首页 > 图文教程 > 网络编程 > ASP > 网址和邮件地址的转换函数

ASP
asp OpenTextFile文本读取与写入实例代码
在ASP编程中nothing代表什么意思?
asp之让Session永不过期
ASP获取ACCESS数据库表名及结构的代码
推荐一篇不错的新手asp编程的基本法则
最简洁的asp多重查询的解决方案
ASP 判断是否有中文的代码
asp.net常用函数收藏
asp下几种常用排序算法
asp获取数据库中表名和字段名的代码
简单的asp采集代码教程
asp生成带有样式的word文件方法
实用301转向到另一域名相应页面的asp代码
asp伪继承初探_实例代码
asp代理采集的核心函数代码
js table排序类代码
ASP UTF-8页面乱码+GB2312转UTF-8 +生成UTF-8格式的文件(编码)
Asp生成RSS的类_给网站加上RSS
utf-8 网页不显示+utf-8网页乱码的通用解决方法
asp截取指定英汉混合字符串_支持中文

ASP 中的 网址和邮件地址的转换函数


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 124 ::
收藏到网摘: n/a

<%
function URLconvert(str) 
convertstr=str
urlLocation=instr(convertstr,"http://")
if (urlLocation=0) and (mailLocation=0) then 
URLconvert=convertstr
exit function
end if
if urlLocation<>0 then
rightstr=str
Do while urlLocation<>urlLocationend
urlLocation=instr(rightstr,"http://")
urlLocationend=InStrRev(rightstr,"http://")
finalstr=finalstr&left(rightstr,urlLocation-1)
midurlstr=mid(rightstr,urlLocation+1,1)
do while (asc(midurlstr)>=45) and (asc(midurlstr)<=126)
loopint=loopint+1
midurlstr=mid(rightstr,urlLocation+loopint,1)
if midurlstr="" then exit do
loop
endURLstr=mid(rightstr,urllocation,loopint)
URLstr="<a href="&endURLstr&">"&endURLstr&"</a>"
rightstr=mid(rightstr,urllocation+loopint)
finalstr=finalstr&URLstr
loopint=1
Loop 
end if
finalstr=finalstr&rightstr
convertstr1=finalstr
finalstr=""
mailLocation=instr(convertstr1,"@")
if mailLocation<>0 then
Do while mailLocation<>mailLocationend
mailLocation=instr(convertstr1,"@")
mailLocationend=InStrRev(convertstr1,"@")
mainmidmailstr=mid(convertstr1,mailLocation+1,1)
midmailstr=mainmidmailstr
do while (asc(midmailstr)>=45) and (asc(midmailstr)<=126)
loopint1=loopint1+1
midmailstr=mid(convertstr1,mailLocation-loopint1,1)
loop
firstSTR=mid(convertstr1,mailLocation-loopint1+1,loopint1-1)
finalstr=finalstr&left(convertstr1,mailLocation-loopint1)
midmailstr1=mainmidmailstr 
do while (asc(midmailstr1)>=45) and (asc(midmailstr1)<=126)
loopint2=loopint2+1
midmailstr1=mid(convertstr1,mailLocation+loopint2,1)
if midmailstr1="" then exit do
loop
secondSTR=mid(convertstr1,mailLocation,loopint2)
endmailstr=firstSTR&secondSTR
mailstr="<a href=mailto:"&endmailstr&">"&endmailstr&"</a>"
finalstr=finalstr&mailstr
convertstr1=mid(convertstr1,maillocation+loopint2)
loopint1=1
loopint2=1
Loop
end if
finalstr=finalstr&convertstr1
URLconvert=finalstr
end function
%>