這個我這裡自己一直用的幾個函數,下面貼出來。
希望盡量不是直接要執行個體就去用,而不關心他本來的意義和實作思路等。加油!
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
///
/// 對字元串進行檢查和替換其中的特殊字元
public static string HtmlToTxt(string strHtml)
{
string[] aryReg ={
@"<script[^>]*?>.*?</script>",
@"<(///s*)?!?((/w+:)?/w+)(/w+(/s*=?/s*(([""’])(//[""’tbnr]|[^/7])*?/7|/w+)|.{0})|/s)*?(///s*)?>",
@"([/r/n])[/s]+",
@"&(quot|#34);",
@"&(amp|#38);",
@"&(lt|#60);",
@"&(gt|#62);",
@"&(nbsp|#160);",
@"&(iexcl|#161);",
@"&(cent|#162);",
@"&(pound|#163);",
@"&(copy|#169);",
@"(/d+);",
@"-->",
@"