首页 > 其他 > 详细

正则表达式获取TABLE里的内容

时间:2016-09-09 13:36:27      阅读:247      评论:0      收藏:0      [点我收藏+]

//过滤\n 转换成空
            String withoutNString=message.Replace("\n", "");
            //过滤\r 转换成空
            String withoutRString = withoutNString.Replace("\r", "");
            //过滤\t 转换成空
            String withoutTString = withoutRString.Replace("\t", "");
            //过滤\ 转换成空
            String newString = withoutTString.Replace("\\", "");
            //获取html中的body标签
            String result = Regex.Match(newString, @"<body.*>.*</body>").ToString();
            //过滤注释
            String result2 = Regex.Replace(result, @"<!--(?s).*?-->", "", RegexOptions.IgnoreCase);
            //过滤nbsp标签
            String result3 = Regex.Replace(result2, @"&nbsp;", "", RegexOptions.IgnoreCase);
            //获取body中的所有table
            Regex regex = new Regex(@"<table.*?>[\s\S]*?<\/table>");
            MatchCollection mc = regex.Matches(result3);
            //获取集合类中自己需要的某个table
            String newHtmlStr = mc[3].ToString();

正则表达式获取TABLE里的内容

原文:http://www.cnblogs.com/XuPengLB/p/5856226.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!