Skip to content

Instantly share code, notes, and snippets.

@Olical
Created September 14, 2011 10:58
Show Gist options
  • Select an option

  • Save Olical/1216308 to your computer and use it in GitHub Desktop.

Select an option

Save Olical/1216308 to your computer and use it in GitHub Desktop.
Replace MarkDown links with HTML links
function htmlLinks(md) {
return md.replace(/\[(.*?)\]\((.*?)\)/ig, '<a href=\'$2\'>$1</a>');
}
htmlLinks('This is now [linked to Google](http://www.google.co.uk/).'); // This is now <a href='http://www.google.co.uk/'>linked to Google</a>.
Find: \[(.*?)\]\((.*?)\)
Replace: <a href='$2'>$1</a>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment