Skip to content

Instantly share code, notes, and snippets.

@darkowlzz
Created December 28, 2013 06:31
Show Gist options
  • Save darkowlzz/8156688 to your computer and use it in GitHub Desktop.
Save darkowlzz/8156688 to your computer and use it in GitHub Desktop.
var mystring = "hey there, here is the link http://www.mozilla.org yah!";
REGEX = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;
function doIt(match) {
return "<a href='" + match + "'> " + match + "</a>";
}
console.log(mystring.replace(REGEX, doIt));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment