I\'m trying to do a parse of html content using jQuery/Javascript. I want to look for words between square brackets and change the whole word for a link.
Example:
$("div").html(function(i, html) {
return html.replace(/\[\[(.+?)\]\]/g, "<a href='/dictionary#$1'>$1</a>");
});
DEMO: http://jsfiddle.net/y4N6e/
Something like:
$('div').html($('div').html().replace(/\[\[([^\]]+)\]\]/, '<a href="/dictionary#$1">$1</a>')
should work.
But you should hava a look to _.template method!.