How can I remove the (//<![CDATA[ , //]]>
) blocks; tags inside a script
element.
<script type="text/javascript">
//<![CDATA[
var l=new Array();
..........................
..........................
//]]>
</script>
Looks like it can be done with preg_replace()
but havent found a solution that works for me.
What regex would I use?
use
str_replace()
instead ofpreg_replace()
it's lot easierI use like this to remove
<![CDATA[]]
but on single line now work for me, dont know if for multiple line string.If you must...
This will remove the whole line containing each tag without messing up the indentation of the enclosed code.
You can also try,
You don't need regex for a static string.
Replace those parts of the texts with nothing: