Due to the way jQuery deals with script tags, I found it necessary to do some manipulation using regular expressions (yes, I know ... not an ideal tool to work with). Unfortunately, it seems to me that my understanding of how the captured groups work in JavaScript is wrong, because when I try to do this:
var scriptTagFormat = /<script .*?(src="(.*?)")?.*?>(.*?)<\/script>/ig;
html = html.replace(
scriptTagFormat,
'<span class="script-placeholder" style="display:none;" title="$2">$3</span>');
Script tags are replaced with spaces, but the resulting attribute is titleempty. Shouldn't $2match the contents of the attribute of the srcscript tag?
Jacob source
share