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

2018-09-06 10:54

阅读:521

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

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

ifurlLocation<>0then
rightstr=str
DowhileurlLocation<>urlLocationend
urlLocation=instr(rightstr,
urlLocationend=InStrRev(rightstr,
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
%>


评论


亲,登录后才可以留言!