Using ASP to realize the conversion function of URL and email address
Source: Internet
Author: User
Conversion functions for URLs and email addresses
<%
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)
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
%>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service