Return to Snippet

Revision: 8270
at September 11, 2008 09:40 by DaveChild


Initial Code
function create_links(strText)
    strText = " " & strText
    strText = ereg_replace(strText, "(^|[\n ])([\w]+?://[^ ,""\s<]*)", "$1<a href=""$2"">$2</a>")
    strText = ereg_replace(strText, "(^|[\n ])((www|ftp)\.[^ ,""\s<]*)", "$1<a href=""http://$2"">$2</a>")
    strText = ereg_replace(strText, "(^|[\n ])([a-z0-9&\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)", "$1<a href=""mailto:$2@$3"">$2@$3</a>")
    strText = right(strText, len(strText)-1)
    create_links = strText
end function
 
function ereg_replace(strOriginalString, strPattern, strReplacement)
    ' Function replaces pattern with replacement
    dim objRegExp : set objRegExp = new RegExp
    objRegExp.Pattern = strPattern
    objRegExp.IgnoreCase = True
    objRegExp.Global = True
    ereg_replace = objRegExp.replace(strOriginalString, strReplacement)
    set objRegExp = nothing
end function

Initial URL
http://www.addedbytes.com/asp/automatically-convert-urls/

Initial Description


Initial Title
VBScript Clickable URLs and Email Addresses

Initial Tags


Initial Language
ASP