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

推荐订阅源

Scott Helme
Scott Helme
Cisco Talos Blog
Cisco Talos Blog
I
Intezer
P
Privacy International News Feed
T
Threatpost
P
Palo Alto Networks Blog
Cyberwarzone
Cyberwarzone
V
Vulnerabilities – Threatpost
L
Lohrmann on Cybersecurity
C
CERT Recently Published Vulnerability Notes
C
Cisco Blogs
Simon Willison's Weblog
Simon Willison's Weblog
C
Cyber Attacks, Cyber Crime and Cyber Security
T
Tenable Blog
Know Your Adversary
Know Your Adversary
量子位
T
The Exploit Database - CXSecurity.com
G
Google Developers Blog
N
Netflix TechBlog - Medium
酷 壳 – CoolShell
酷 壳 – CoolShell
C
Cybersecurity and Infrastructure Security Agency CISA
罗磊的独立博客
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
腾讯CDC
I
InfoQ
The Hacker News
The Hacker News
S
Schneier on Security
Recorded Future
Recorded Future
C
CXSECURITY Database RSS Feed - CXSecurity.com
Latest news
Latest news
T
Threat Research - Cisco Blogs
Security Latest
Security Latest
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
S
Securelist
AWS News Blog
AWS News Blog
NISL@THU
NISL@THU
L
LangChain Blog
GbyAI
GbyAI
T
Tor Project blog
Last Week in AI
Last Week in AI
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
F
Fortinet All Blogs
Recent Announcements
Recent Announcements
爱范儿
爱范儿
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
博客园 - Franky
P
Proofpoint News Feed
G
GRAHAM CLULEY
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Martin Fowler
Martin Fowler

博客园 - 努力前上

button按回车触发后台 - 努力前上 - 博客园 Connectionstrings - 努力前上 - 博客园 [C#]包含DataSet类的XML架构怎么不自动生成CS文件了(XSD和CS文件不能合并) Asp.Net 备份和恢复SQL SERVER 数据库 危险字符过滤的类(最新完善版)(1) Tree使用 常用的一些javascript小技巧(转) 利用TreeView控件动态生成无限级树(续:通过绑定动态xml文件)(转) - 努力前上 - 博客园 利用TreeView控件动态生成无限级树(转) - 努力前上 - 博客园 Microsfot.Web.UI.WebControls.TreeView JavaScript控制方法研究(转) (二)execCommand()函数可用参数大解析 JavaScript--execCommand指令集 JS 无刷新排序 js 技巧杂引(转) HTML代码过滤函数 DataGrid 颜色交替 DataGrid双击事件 javascript调用webservice [垃圾猪]防盗链IHttpHandler源码
提取HTML代码中文字的C#函数 (转) - 努力前上 - 博客园
努力前上 · 2006-03-30 · via 博客园 - 努力前上

/// <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;
  }