How to remove // and end //]]> with javascript from string?
// and end //]]> with javascript from string?
//]]>
var title = \"
I suggest this wider way to remove leading and trailing CDATA stuff :
title.trim().replace(/^(\/\/\s*)?$/g, '')
It will also work if CDATA header and footer are commented.