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


//过滤\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();


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM