[转]提取HTML代码中文字的C#函数
来源:互联网 发布:js触发div的点击事件 编辑:程序博客网 时间:2024/04/29 02:08
/// <summary>
/// 去除HTML标记
/// </summary>
/// <param name="strHtml">包括HTML的源码 </param>
/// <returns>已经去除后的文字</returns>
public static string StripHTML(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+);",
@"-->",
@"<!--.*/n"
};
string [] aryRep = {
"",
"",
"",
"/"",
"&",
"<",
">",
" ",
"/xa1",//chr(161),
"/xa2",//chr(162),
"/xa3",//chr(163),
"/xa9",//chr(169),
"",
"/r/n",
""
};
string newReg =aryReg[0];
string strOutput=strHtml;
for(int i = 0;i<aryReg.Length;i++)
{
Regex regex = new Regex(aryReg[i],RegexOptions.IgnoreCase );
strOutput = regex.Replace(strOutput,aryRep[i]);
}
strOutput.Replace("<","");
strOutput.Replace(">","");
strOutput.Replace("/r/n","");
return strOutput;
}
- [转]提取HTML代码中文字的C#函数
- 提取HTML代码中文字的C#函数
- 提取HTML代码中文字的C#函数
- 提取HTML代码中文字的C#函数
- 提取HTML代码中文字的C#函数
- 提取HTML代码中文字的C#函数
- 提取HTML代码中文字的C#函数
- 提取HTML代码中文字的C#函数
- 提取HTML代码中文字的C#函数
- 提取HTML代码中文字的C#函数
- 提取HTML代码中文字的C#函数
- 提取HTML代码中文字的C#函数
- 提取HTML代码中文字的C#函数(HTML to TEXT)
- 从HTML代码中提取文字,去掉HTML的标记
- C#提取HTML代码中的文字zt
- C#提取HTML代码中的文字
- C#提取HTML代码中的文字
- C#提取HTML代码中的文字
- CRTMBR
- 完整的TCP通信包实现
- 十项Linux安全管理技巧经验总结
- TCP/IP基础讲座
- cygwin下建立cvs仓库
- [转]提取HTML代码中文字的C#函数
- 日记本的第一页
- VC常用知识
- [转]35岁前必须做好十件事
- Hibernate 3.0 released!
- Eclipse 相关的一些资源
- 一个free ebook/other resource的站点
- NTLDR文件丢失如何解决
- 20个发人深思地寓言故事