Berikut ini adalah function Javascript untuk menggantikan URL dalam bentuk teks biasa menjadi hyperlink yang bisa diklik pada HTML.
function replaceURLWithHTMLLinks(text) { // this looks for urls in html and makes them links // I apologize in advance var exp = /(b(https?|ftp|file)://[-A-Z0-9+&@#/%?=~_|!:,.;]*[-A-Z0-9+&@#/%=~_|])/ig; return text.replace(exp, "<a href='$1'>$1</a>"); }
Sumber
http://recurial.com/programming/javascript-snippet-replace-urls-with-hyperlinks/