Good code, of course, keep it. Haha
:
Method 1:
Private static readonly Regex REGEX_LINE_BREAKS = new Regex (@ "\ n \ s *", RegexOptions. Compiled );
Private static readonly Regex REGEX_LINE_SPACE = new Regex (@ "\ n \ s * \ r", RegexOptions. Compiled );
Private static readonly Regex REGEX_SPACE = new Regex (@ "() +", RegexOptions. Compiled );
Protected override void Render (HtmlTextWriter writer)
{
Using (HtmlTextWriter htmlwriter = new HtmlTextWriter (new System. IO. StringWriter ()))
{
Base. Render (htmlwriter );
String html = htmlwriter. InnerWriter. ToString ();
Html = REGEX_LINE_BREAKS.Replace (html, string. Empty );
Html = REGEX_LINE_SPACE.Replace (html, string. Empty );
Html = REGEX_SPACE.Replace (html ,"");
Writer. Write (html. Trim ());
}
}
Method 2:
Private static readonly Regex regReplaceBlank = new Regex ("> (\ s +) <", RegexOptions. IgnoreCase );
Private static readonly Regex regReplaceLine = new Regex ("\ s \ n", RegexOptions. IgnoreCase );
Protected override void Render (HtmlTextWriter writer)
{
Using (HtmlTextWriter htmlwriter = new HtmlTextWriter (new System. IO. StringWriter ()))
{
Base. Render (htmlwriter );
String html = htmlwriter. InnerWriter. ToString ();
Html = regReplaceBlank. Replace (regReplaceLine. Replace (html, ""), "> <");
Writer. Write (html. Trim ());
}
}
Method 3: www.2cto.com
Private static readonly Regex REGEX_LINE_BREAKS = new Regex (@ "\ n \ s *", RegexOptions. Compiled );
Private static readonly Regex REGEX_LINE_SPACE = new Regex (@ "\ n \ s * \ r", RegexOptions. Compiled );
Private static readonly Regex REGEX_SPACE = new Regex (@ "() +", RegexOptions. Compiled );
Private static readonly Regex regReplaceBlank = new Regex ("> (\ s +) <", RegexOptions. IgnoreCase );
Private static readonly Regex regReplaceLine = new Regex ("\ s \ n", RegexOptions. IgnoreCase );
Protected override void Render (HtmlTextWriter writer)
{
Using (HtmlTextWriter htmlwriter = new HtmlTextWriter (new System. IO. StringWriter ()))
{
Base. Render (htmlwriter );
String html = htmlwriter. InnerWriter. ToString ();
Html = REGEX_LINE_BREAKS.Replace (html, string. Empty );
Html = REGEX_LINE_SPACE.Replace (html, string. Empty );
Html = REGEX_SPACE.Replace (html ,"");
Html = regReplaceBlank. Replace (regReplaceLine. Replace (html, ""), "> <");
Writer. Write (html. Trim ());
}
}
From the column jacky_163