convert text links to clickable links


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



Copy this code and paste it in your HTML
  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. }

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.