用asp实现网址和邮件地址的转换函数

时间:2021-05-18

网址和邮件地址的转换函数
<%
functionURLconvert(str)
convertstr=str
urlLocation=instr(convertstr,"http://")

if(urlLocation=0)and(mailLocation=0)then
URLconvert=convertstr
exitfunction
endif

ifurlLocation<>0then
rightstr=str
DowhileurlLocation<>urlLocationend
urlLocation=instr(rightstr,"http://")
urlLocationend=InStrRev(rightstr,"http://")
finalstr=finalstr&left(rightstr,urlLocation-1)
midurlstr=mid(rightstr,urlLocation+1,1)
dowhile(asc(midurlstr)>=45)and(asc(midurlstr)<=126)
loopint=loopint+1
midurlstr=mid(rightstr,urlLocation+loopint,1)
ifmidurlstr=""thenexitdo
loop
endURLstr=mid(rightstr,urllocation,loopint)
URLstr="<ahref="&endURLstr&">"&endURLstr&"</a>"
rightstr=mid(rightstr,urllocation+loopint)
finalstr=finalstr&URLstr
loopint=1
Loop
endif
finalstr=finalstr&rightstr

convertstr1=finalstr
finalstr=""
mailLocation=instr(convertstr1,"@")
ifmailLocation<>0then
DowhilemailLocation<>mailLocationend
mailLocation=instr(convertstr1,"@")
mailLocationend=InStrRev(convertstr1,"@")
mainmidmailstr=mid(convertstr1,mailLocation+1,1)
midmailstr=mainmidmailstr
dowhile(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
dowhile(asc(midmailstr1)>=45)and(asc(midmailstr1)<=126)
loopint2=loopint2+1
midmailstr1=mid(convertstr1,mailLocation+loopint2,1)
ifmidmailstr1=""thenexitdo
loop
secondSTR=mid(convertstr1,mailLocation,loopint2)

endmailstr=firstSTR&secondSTR
mailstr="<ahref=mailto:"&endmailstr&">"&endmailstr&"</a>"
finalstr=finalstr&mailstr
convertstr1=mid(convertstr1,maillocation+loopint2)
loopint1=1
loopint2=1
Loop
endif
finalstr=finalstr&convertstr1
URLconvert=finalstr
endfunction
%>

声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。

相关文章