title: Remove almost all HTML comments using Regex
body: <p>Using this regex expression:</p>
  
  <pre><code>preg_replace( '/&lt;!--(?!&lt;!)[^\[&gt;].*?--&gt;/', '', $output )
  </code></pre>
  
  <p>I'm able to remove all HTML comments from my page except for anything that looks like this:</p>
  
  <pre><code>&lt;!--[if IE 6]&gt;
      Special instructions for IE 6 here
  &lt;![endif]--&gt;
  </code></pre>
  
  <p>How can I modify this to also exclude HTML comments which include a unique phrase, such as "batcache"?</p>
  
  <p>So, an HTML comment this:</p>
  
  <pre><code>&lt;!--
  generated 37 seconds ago
  generated in 0.978 seconds
  served from batcache in 0.004 seconds
  expires in 263 seconds
  --&gt;
  </code></pre>
  
  <p>Won't be removed.</p>
  
  <hr>
  
  <p>This code seems to do the trick:</p>
  
  <pre><code>preg_replace( '/&lt;!--([\s\S]*?)--&gt;/', function( $c ) { return ( strpos( $c[1], '&lt;![' ) !== false || strpos( $c[1], 'batcache' ) !== false ) ? $c[0] : ''; }, $output )
  </code></pre>