Removes the HTML whitespace.
using System;
using System.IO;
using System.Net.Mail;
using System.Collections.Generic;
using System.Security.Cryptography;
using System.Text;
using System.Text.RegularExpressions;
using System.Configuration;
using System.Globalization;
using System.Web;
using System.Web.Configuration;
using System.Threading;
using System.Reflection;
using System.Collections;
using System.Xml;
using System.Net;
using System.Web.Caching;
namespace BlogEngine.Core
{
/// <summary>
/// Utilities for the entire solution to use.
/// </summary>
public static class Utils
{
private static readonly Regex REGEX_BETWEEN_TAGS = new Regex(@">\s+", RegexOptions.Compiled);
private static readonly Regex REGEX_LINE_BREAKS = new Regex(@"\n\s+", RegexOptions.Compiled);
/// <summary>
/// Removes the HTML whitespace.
/// </summary>
/// <param name="html">The HTML.</param>
public static string RemoveHtmlWhitespace(string html)
{
if (string.IsNullOrEmpty(html))
return string.Empty;
html = REGEX_BETWEEN_TAGS.Replace(html, "> ");
html = REGEX_LINE_BREAKS.Replace(html, string.Empty);
return html.Trim();
}
}
}
Related examples in the same category