I am new to regex, but I need code that removes all html comments ( <!-- here -->
), but not comments in Internet Explorer, such as ( <!--[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.
source share