/// <summary>
/// 将Html标签转化为空 贾世义
/// </summary>
/// <param name="strHtml">待转化的字符串</param>
/// <returns>经过转化的字符串</returns>
public static string GetStringNoHtml(string strHtml)
{
if (String.IsNullOrEmpty(strHtml))
{
return strHtml;
}
else
{
string[] aryReg ={
@"<script[^>]*?>.*?</script>",
@"<!--.*\n(-->)?",
@"<(\/\s*)?(.|\n)*?(\/\s*)?>",
@"<(\w|\s|""|'| |=|\\|\.|\/|#)*",
@"([\r\n|\s])*",
@"&(quot|#34);",
@"&(amp|#38);",
@"&(lt|#60);",
@"&(gt|#62);",
@"&(nbsp|#160);",
@"&(iexcl|#161);",
@"&(cent|#162);",
@"&(pound|#163);",
@"&(copy|#169);",
@"&#(\d+);"};
string newReg = aryReg[0];
string strOutput = strHtml.Replace(" ", " ");
for (int i = 0; i < aryReg.Length; i++)
{
Regex regex = new Regex(aryReg[i], RegexOptions.IgnoreCase);
strOutput = regex.Replace(strOutput, "");
}
strOutput.Replace("<", ">");
strOutput.Replace(">", "<");
return strOutput.Replace(" ", " ");
}
}
欢迎访问:http://121.18.78.216 适易查询分析、工作流、内容管理及项目管理演示平台