CopyCode The Code is as follows: function autolinkurls (strstring)
Dim match, matches, offset, URL, email, Link, relnkautolinkurl
Relnkautolinkurl = "<a href =" "[[% URL %]" "> [% urltext %] </a>"
If not isobject (Regexp) then set Regexp = new Regexp
Regexp. Global = true
Regexp. ignorecase = true
'Look for URLs
Regexp. pattern = "(HT | f) TPS? : //) | (Www \.) ([\ W-] + \.) + [\ W-:] + (/[\ W -./? % #; & =] *)? "
Set matches = Regexp. Execute (strstring)
Offset = 0
For each match in matches
Url = match
If left (URL, 4) = "www." Then url = "http: //" & URL
Link = Replace (replace (relnkautolinkurl, "[[% urltext %]", match), "[[% URL %]", URL)
Strstring = mid (strstring, 1, match. firstindex + offset) & link & Mid (strstring, match. firstindex + 1 + match. Length + offset, Len (strstring ))
Offset = offset + Len (Link)-len (MATCH)
Next
'Look for emails
Regexp. pattern = "[A-Za-z0-9 _ + -. '] + @ \ W + ([-.] \ W + )*\. \ W + ([-.] \ W + )*"
Set matches = Regexp. Execute (strstring)
Offset = 0
For each match in matches
Email = match
Link = Replace (replace (relnkautolinkurl, "[[% urltext %]", match), "[[% URL %]", "mailto:" & Email)
Strstring = mid (strstring, 1, match. firstindex + offset) & link & Mid (strstring, match. firstindex + 1 + match. Length + offset, Len (strstring ))
Offset = offset + Len (Link)-len (MATCH)
Next
Autolinkurls = strstring
End Function