欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

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

程序员文章站 2022-05-03 13:33:45
网址和邮件地址的转换函数<% function urlconvert(str)  convertstr=str urllocation=instr...
网址和邮件地址的转换函数
<%
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
%>