Skip to content

Instantly share code, notes, and snippets.

@jookyboi
Created March 30, 2011 03:41
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 jookyboi/893822 to your computer and use it in GitHub Desktop.
Save jookyboi/893822 to your computer and use it in GitHub Desktop.
Linkify urls in plain text.
// from: http://stackoverflow.com/questions/37684/replace-url-with-html-links-javascript
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