Skip to content

Instantly share code, notes, and snippets.

@tylerbuchea
Created April 29, 2013 17:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tylerbuchea/5483369 to your computer and use it in GitHub Desktop.
Save tylerbuchea/5483369 to your computer and use it in GitHub Desktop.
Turns urls within a block of text into hyperlinks.
function linkify(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