Posted By

jfoucher on 08/26/11


Tagged


Versions (?)

convert text links to clickable links


 / Published in: JavaScript
 

URL: http://stackoverflow.com/questions/5180877/convert-text-url-into-clickable-links

  1. function replaceURLWithHTMLLinks(text) {
  2. var exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
  3. return text.replace(exp,"<a href='$1'>$1</a>");
  4. }

Report this snippet  

You need to login to post a comment.