去处HTML代码中的格式

/// <summary>
/// 方法接收一段HTML代码,返回一段代码
/// </summary>
/// <param name="strHtmlCode"></param>
/// <returns></returns>

public string replaceHtmlCode(string strHtmlCode)
{
       string strCode = strHtmlCode.ToString();

       if (strCode.ToString() == "")
       {
           return "";
       }
       else
       {
           strCode = strCode.Replace("<P>", "♂");
           strCode = strCode.Replace("</P>", "♀");
           strCode = strCode.Replace("<BR>", "¢");

           Regex rgx = new Regex(@"<[^>]*>");
           strCode = rgx.Replace(strCode.ToString(), "");
           strCode = strCode.Replace("♂", "");
           strCode = strCode.Replace("♀", "<BR>");
           strCode = strCode.Replace("¢", "<BR>");

           return strCode;
       }

}

原文地址:https://www.cnblogs.com/zhangpengshou/p/856443.html