I am new in regex but need a code that would remove all html comments (<!-- here -->
) but not internet explorer comments like (<!--[if IE 7]> here <![endif]-->
). I have this code:
369
<?php
function stripTags($text, $tags)
{
// replace the internet explorer comments tags so they do not get stripped
$text = preg_replace("<!--[if IE7] (.*?) <![endif]-->", "#?#", $text);
// replace all the normal html comments
$text =preg_replace('/<!--(.|\n)*?-->/g', '', $&text);
// return internet explorer comments tags to their origial place
$text = preg_replace("@#\?#@", "<!--[if IE7] (.*?) <![endif]-->", $text);
return $text;
}
?>
Any help please.