Issue
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?
Solution
The following regex will do it...
$removed = preg_replace('/^\s*\/\/<!\[CDATA\[([\s\S]*)\/\/\]\]>\s*\z/',
'$1',
$scriptText);
Answered By - alex Answer Checked By - Robin (PHPFixing Admin)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.