惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
GbyAI
GbyAI
F
Fortinet All Blogs
Y
Y Combinator Blog
I
InfoQ
Microsoft Azure Blog
Microsoft Azure Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
Vercel News
Vercel News
T
The Blog of Author Tim Ferriss
P
Proofpoint News Feed
S
Schneier on Security
NISL@THU
NISL@THU
The Hacker News
The Hacker News
Simon Willison's Weblog
Simon Willison's Weblog
The GitHub Blog
The GitHub Blog
MyScale Blog
MyScale Blog
Cisco Talos Blog
Cisco Talos Blog
F
Full Disclosure
P
Palo Alto Networks Blog
T
The Exploit Database - CXSecurity.com
Know Your Adversary
Know Your Adversary
A
About on SuperTechFans
The Cloudflare Blog
T
Threat Research - Cisco Blogs
M
MIT News - Artificial intelligence
宝玉的分享
宝玉的分享
雷峰网
雷峰网
Hugging Face - Blog
Hugging Face - Blog
博客园 - 三生石上(FineUI控件)
D
DataBreaches.Net
Martin Fowler
Martin Fowler
H
Help Net Security
B
Blog RSS Feed
B
Blog
爱范儿
爱范儿
V
V2EX
I
Intezer
L
LangChain Blog
WordPress大学
WordPress大学
小众软件
小众软件
美团技术团队
Latest news
Latest news
H
Hackread – Cybersecurity News, Data Breaches, AI and More
T
Tor Project blog
L
Lohrmann on Cybersecurity
Cyberwarzone
Cyberwarzone
Last Week in AI
Last Week in AI
Project Zero
Project Zero
C
Cybersecurity and Infrastructure Security Agency CISA
V
Visual Studio Blog

博客园 - refuly

【半原创】将js和css文件装入localStorage加速程序执行 SqlAgent备份脚本 ASP.net 使用HttpHandler实现图片防盗链 水晶头的制作 解决ASP.NET“类型初始值设定项引发异常” 解决vs2005 经WebDeployment发布后 global.asax 事件不启动 C# 实现Epson热敏打印机打印 Pos机用 去掉文件名中的非法字符 - refuly - 博客园 window.onbeforeunload与window.onunlad对比 用Response.Filter生成静态页[要注意并发问题] HttpModule通过修改CSS切换皮肤 asp.net Excel导入&导出 - refuly - 博客园 计算机端口的介绍 Sql Server数据导出EXCEL 获取字符串的真实长度 c# 小数位数处理 新旧身份证合法性验证及验证算法 C#进制转换 Asp.net 备份、还原Ms SQLServer及压缩Access数据库
提取HTML代码中文字的C#函数 - refuly - 博客园
refuly · 2010-07-05 · via 博客园 - refuly
/// <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;
}