class="f14" title="2013年中考数学二轮专题复习之一.doc">2013年中考数学二轮专题复习之一.doc</a></td>class="f14" title="2013年中考数学二轮专题复习之三.doc">2013年中考数学二轮专题复习之三.doc</a></td>class="f14" title="2013年中考数学二轮专题复习之五.doc">2013年中考数学二轮专题复习之五.doc</a></td>class="f14" title="2012佛山中考数学卷.doc">2012佛山中考数学卷.doc</a></td>想取出其中的:
2013年中考数学二轮专题复习之一.doc
2013年中考数学二轮专题复习之三.doc
2013年中考数学二轮专题复习之五.doc
2012佛山中考数学卷.doc
这样的应该要怎么获取呢?
要全部都取出来。

解决方案 »

  1.   


                StreamReader reader = new StreamReader("c:\\1.txt",Encoding.Default);
                string source = reader.ReadToEnd();
                Regex reg = new Regex(@"(?is)(?<=>)[^<>]*?(?=</a>)");
                MatchCollection mc = reg.Matches(source);
                foreach (Match m in mc)
                {
                    MessageBox.Show(m.Value);
                }
      

  2.   

    <a\b[^>]*?class="f14"[^>]*?>(.*?)</a>string input="HTML源码";
    string pattern=@"(?is)<a\b[^>]*?class=""f14""[^>]*?>(.*?)</a>";
    List<string> list=new List<string>();
    foreach(Match m in Regex.Matches(input,pattern))
    {
      list.Add(m.Groups[1].Value);//list就是你要的
    }
      

  3.   

    大哥,你这个取的是取<>这里的<>,我要求没写清楚,是要取:title="后面的,就是title=""引号中间的。
      

  4.   

    Regex reg = new Regex(@"(?is)(?<=title="")[^""]*?(?="")");
      

  5.   

     string tempStr = File.ReadAllText(@"C:\Documents and Settings\Administrator\桌面\Test.txt", Encoding.GetEncoding("GB2312"));//读取txt
                    string pattern = @"(?i)(?<=title=['""])[^'""]*?(?=['""]?>)";
                    List<string> list = Regex.Matches(tempStr, pattern).Cast<Match>().Select(a => a.Value).ToList();
      

  6.   

    虽然大哥这个已经可以正确取到包括扩展名了,但是我那个网页中还有好一些是包括title="",所以要靠前面的class="f14" 来区别,感谢大哥。原来是两个人回答的,我以为是一个的。嘎嘎。
      

  7.   

    多谢各位我已经研究出来了。
    事实上是这样的。
    @"(?is)(?<=class=""f14"" title="")[^""]*?(?="")";
    结贴咯~