using System.Text.RegularExpressions; //正则表达式命名空间

public class HtmlFilter
{
public static string Filter(string tagHtml)
{
string RegExp = "<[^>]+> "; //替换所有html双标记
string Result = Regex.Replace(tagHtml, RegExp, " ");
RegExp = "<*> "; //替换所有html单标记
Result = Regex.Replace(Result, RegExp, string.Empty);
RegExp = "<* /> "; //替换所有html w3c标准单标记
Result = Regex.Replace(Result, RegExp, string.Empty);
return Result;
}
}

2.........
 

/// 除去所有在HTML元素中标记
public static string StripHTML(string strHtml)
{
string strOutput=strHtml;
Regex regex = new Regex(@"<[^>] >|] >");
strOutput = regex.Replace(strOutput,"");
return strOutput;

}

posted on 2008-05-14 13:37  goooto  阅读(166)  评论(0)    收藏  举报