Skip to content

Instantly share code, notes, and snippets.

@tylerthebuildor
Created April 29, 2013 17:50
Show Gist options
  • Save tylerthebuildor/5483369 to your computer and use it in GitHub Desktop.
Save tylerthebuildor/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