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

2018-09-06 09:48

阅读:929

  <%
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=finalstrleft(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=finalstrURLstr
loopint=1
Loop
endif
finalstr=finalstrrightstr
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=finalstrleft(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=firstSTRsecondSTR
mailstr=<ahref=mailto:endmailstr>endmailstr</a>
finalstr=finalstrmailstr
convertstr1=mid(convertstr1,maillocation+loopint2)
loopint1=1
loopint2=1
Loop
endif
finalstr=finalstrconvertstr1
URLconvert=finalstr
endfunction
%>


评论


亲,登录后才可以留言!