正则匹配百度结果

重点是先抓取<td>里的内容,其它的就好说了:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Text.RegularExpressions;

namespace ReadFile
{
    class Program
    {
        static void Main(string[] args)
        {
            string FilePath = @"E:\vs\bd.txt";
            StreamReader sr = new StreamReader(FilePath,Encoding.GetEncoding("UTF-8"));
            string FileContent = sr.ReadToEnd();
            FileContent = Regex.Replace(FileContent,"[\r\n\t]+","");
            string PatternTable = "(?i)<table class=\"result\"[^>]*?>(?:(?!</?table>)[\\s\\S])*?</table>";
            string PatternBlock = "<td class=\"c-default\" >(?:(?!</?td>)[\\s\\S])*?</td>";
            MatchCollection mc = Regex.Matches(FileContent,PatternBlock,RegexOptions.Multiline);
            Match mm = Regex.Match(FileContent,RegexOptions.Multiline);
            //Debug.WriteLine(mm.Groups.Count);
            foreach (Match mat in mc)
            {
                Console.WriteLine("================================================");
                Console.WriteLine(mat.Value);
            }

            Console.Read();
        }
    }
}

相关文章

jquery.validate使用攻略(表单校验) 目录 jquery.validate...
/\s+/g和/\s/g的区别 正则表达式/\s+/g...
自整理几个jquery.Validate验证正则: 1. 只能输入数字和字母...
this.optional(element)的用法 this.optional(element)是jqu...
jQuery.validate 表单动态验证 实际上jQuery.validate提供了...
自定义验证之这能输入数字(包括小数 负数 ) &lt;script ...