title: Remove white space from my aspx page using regex
body: <p>i need to remove few things from my aspx page.
  1) need to remove white space from my aspx page.
  2) need to remove all html &amp; css comment from my aspx page.
  3) need to remove javascript comment like single line &amp; multi line comment</p>
  
  <p>please give me the best code to do the above.</p>
  
  <h2>i search google and found the code below</h2>
  
  <pre><code> protected override void Render(HtmlTextWriter writer)
      {
          using (HtmlTextWriter htmlwriter = new HtmlTextWriter(new System.IO.StringWriter()))
          {
              base.Render(htmlwriter);
              string html = htmlwriter.InnerWriter.ToString();
  
              if ((ConfigurationManager.AppSettings.Get("RemoveWhitespace") + string.Empty).Equals("true", StringComparison.OrdinalIgnoreCase))
              {
                  // regex for removing white space
                  html = Regex.Replace(html, @"(?&lt;=[^])\t{2,}|(?&lt;=[&gt;])\s{2,3}(?=[&lt;])|(?&lt;=[&gt;])\s{2,3}(?=[&lt;])|(?=[\n])\s{2,3}", String.Empty);
  
                  // regex for removing js comment
                  //
  
                  html = Regex.Replace(html, @"(?&lt;=[^])\t{2,}|(?&lt;=[&gt;])\s{2,}(?=[&lt;])|(?&lt;=[&gt;])\s{2,11}(?=[&lt;])|(?=[\n])\s{2,}|(?=[\r])\s{2,}", String.Empty);
                  // regex for removing white space again
                  html = Regex.Replace(html, @"[\f\r\t\v]?([\n\xFE\xFF/{}[\];,&lt;&gt;*%&amp;|^!~?:=])[\f\r\t\v]?", "$1");
                  // regex for removing html comment
                  html = Regex.Replace(html, @"((&lt;!-- )((?!&lt;!-- ).)*( --&gt;))(\r\n)*", String.Empty);
                  // regex for removing line break &amp; carriage return
                  html = Regex.Replace(html, @"((\/\*[\s\S]+?\*\/)|(\/\/.+))", String.Empty);
                  html = html.Replace(";\r\n", ";");
              }
              writer.Write(html.Trim());
          }
      }
  
  the above code remove white space js comment but affect my script tag which is like
  </code></pre>
  
  
  
  <pre><code>&lt;script type="text/javascript"&gt;
      if(!window.jQuery)
      {
           document.write("&lt;script type='text\/javascript' src=&lt;%= this.ResolveClientUrl("~/Scripts/jquery-1.4.1.js") %&gt;&gt;&lt;\/script&gt;");
      }
  &lt;/script&gt;
  </code></pre>
  
  <p>so please show me regex which does not affect <strong>&lt;/script></strong> this type of character in script.
  another request that please give me one regex which will do like
  1) need to remove white space from my aspx page.
  2) need to remove all html &amp; css comment from my aspx page.
  3) need to remove javascript comment like single line &amp; multi line comment</p>
  
  <p>i am expecting optimize code from the forum guys. thanks</p>