VBScript Clickable URLs and Email Addresses


/ Published in: ASP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. function create_links(strText)
  2. strText = " " & strText
  3. strText = ereg_replace(strText, "(^|[\n ])([\w]+?://[^ ,""\s<]*)", "$1<a href=""$2"">$2</a>")
  4. strText = ereg_replace(strText, "(^|[\n ])((www|ftp)\.[^ ,""\s<]*)", "$1<a href=""http://$2"">$2</a>")
  5. strText = ereg_replace(strText, "(^|[\n ])([a-z0-9&\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)", "$1<a href=""mailto:$2@$3"">$2@$3</a>")
  6. strText = right(strText, len(strText)-1)
  7. create_links = strText
  8. end function
  9.  
  10. function ereg_replace(strOriginalString, strPattern, strReplacement)
  11. ' Function replaces pattern with replacement
  12. dim objRegExp : set objRegExp = new RegExp
  13. objRegExp.Pattern = strPattern
  14. objRegExp.IgnoreCase = True
  15. objRegExp.Global = True
  16. ereg_replace = objRegExp.replace(strOriginalString, strReplacement)
  17. set objRegExp = nothing
  18. end function

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.