Posted By

DaveChild on 09/11/08


Tagged

urls clickable


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

nelda751
benrudolph
dan74


VBScript Clickable URLs and Email Addresses


 / Published in: ASP
 

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

  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

Report this snippet  

You need to login to post a comment.