title: Remove white space from entire Html but inside pre with regular expressions
body: <p>On ASP.NET MVC 3, I created a Action Filter for white space removal from the entire html. It works as I expected most of the time but now I need to change the RegEx in order not to touch inside <code>pre</code> element.</p>
  
  <p>I get the RegEx logic from awesome <a href="http://madskristensen.net/" rel="nofollow">Mads Kristensen</a>'s blog and I am not sure how to modify it for this purpose.</p>
  
  <p>Here is the logic:</p>
  
  <pre><code>public override void Write(byte[] buffer, int offset, int count) {
  
      string HTML = Encoding.UTF8.GetString(buffer, offset, count);
  
      Regex reg = new Regex(@"(?&lt;=[^])\t{2,}|(?&lt;=[&gt;])\s{2,}(?=[&lt;])|(?&lt;=[&gt;])\s{2,11}(?=[&lt;])|(?=[\n])\s{2,}");
      HTML = reg.Replace(HTML, string.Empty);
  
      buffer = System.Text.Encoding.UTF8.GetBytes(HTML);
      this.Base.Write(buffer, 0, buffer.Length);
  }
  </code></pre>
  
  <p>Whole code of the filter:</p>
  
  <p><a href="https://github.com/tugberkugurlu/MvcBloggy/blob/master/src/MvcBloggy.Web/Application/ActionFilters/RemoveWhitespacesAttribute.cs" rel="nofollow">https://github.com/tugberkugurlu/MvcBloggy/blob/master/src/MvcBloggy.Web/Application/ActionFilters/RemoveWhitespacesAttribute.cs</a></p>
  
  <p>Any idea?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p><strong>BIG NOTE:</strong></p>
  
  <blockquote>
    <p>My intention is totally not <strong>speed up the response time</strong>. In fact,
    maybe this slows things down. I GZiped the pages and this minification makes me
    gain approx 4 - 5 kb per page which is nothing.</p>
  </blockquote>