Skip to content

Instantly share code, notes, and snippets.

@rkmaier
Created February 13, 2013 20:30
Show Gist options
  • Save rkmaier/4947962 to your computer and use it in GitHub Desktop.
Save rkmaier/4947962 to your computer and use it in GitHub Desktop.
JS: Make urls clickable
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