Created
February 13, 2013 20:30
-
-
Save rkmaier/4947962 to your computer and use it in GitHub Desktop.
JS: Make urls clickable
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function replaceURLWithHTMLLinks(text) { | |
var exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig; | |
return text.replace(exp,"<a href='$1'>$1</a>"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment