Chinaunix首页 | 论坛 | 博客
  • 博客访问: 656231
  • 博文数量: 845
  • 博客积分: 5000
  • 博客等级: 大校
  • 技术积分: 5015
  • 用 户 组: 普通用户
  • 注册时间: 2008-10-15 16:22
文章分类

全部博文(845)

文章存档

2011年(1)

2008年(844)

我的朋友

分类:

2008-10-15 16:36:58

 

        ///提取HTML代码中文字的函数
        ///  


        ///   去除HTML标记
        ///  

        ///   包括HTML的源码  
        ///   已经去除后的文字
        using   System;
        using   System.Text.RegularExpressions;
        public   class   StripHTMLTest{
              public   static   void   Main(){
                  string   s=StripHTML("中国石龙信息平台faddfs龙信息平台 ");
                  Console.WriteLine(s);
              }
              public   static   string   StripHTML(string   strHtml){
                  string   []   aryReg   ={
                              @"]*?>.*?",
                              @"<(\/\s*)?!?((\w+:)?\w+)(\w+(\s*=?\s*(([""'])(*)?>",
                              @"([\r\n])[\s]+",
                              @"&(quot|#34);",
                              @"&(amp|#38);",
                              @"&(lt|#60);",
                              @"&(gt|#62);",
                              @"&(nbsp|#160);",
                              @"&(iexcl|#161);",
                              @"&(cent|#162);",
                              @"&(pound|#163);",
                              @"&(copy|#169);",
                              @"&#(\d+);",
                              @"-->",
                              @"
阅读(406) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~