Created
December 28, 2013 06:31
-
-
Save darkowlzz/8156688 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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