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