Skip to content

Instantly share code, notes, and snippets.

@adammagana
Created August 13, 2012 20:45
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 adammagana/3343970 to your computer and use it in GitHub Desktop.
Save adammagana/3343970 to your computer and use it in GitHub Desktop.
Parse all URLs into anchor tags in a string of text.
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