Created
August 13, 2012 20:45
-
-
Save adammagana/3343970 to your computer and use it in GitHub Desktop.
Parse all URLs into anchor tags in a string of text.
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
function parseURL(raw_text) { | |
var urlRegex = /[A-Za-z]+:\/\/[A-Za-z0-9-_]+\.[A-Za-z0-9-_:%&~\?\/.=]+/g, | |
parsed_text = ''; | |
parsed_text = raw_text.replace(urlRegex, function(url) { | |
return url.link(url); | |
}); | |
return parsed_text; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment