如上图,我想获取选中部分的data-follow内的值,正则我已经写出来了,就是只能获取第一个,以下的都获取不到代码是这样的Regex r = new Regex(@"(?is)data-follow=""([^""]+)""");
             foreach (HtmlElement he in myWeibo.Document.GetElementsByTagName("li"))
             {
                 //Regex reg = new Regex(@"(?is)title=""([^""]+)"" href=""([^""]+)""");                 if (he.GetAttribute("classname") == "clearfix")
                 {
                     Match mm = r.Match(he.InnerHtml);
                     MessageBox.Show(mm.Groups[1].Value);
                 }
             }求高手解答,我想获取uid=后面的数字,和fnick=后面的名字,谢谢高手啦,在线等,急急急

解决方案 »

  1.   

    foreach中的he.InnerHtml内容是什么,foreach是否只迭代一次
      

  2.   

    迭代了很多次啊,但是这个网页上有很多,classname=“clearfix”的
      

  3.   

    Regex regex = new Regex("(?<=data-follow=\").*?(?=\")");
    MatchCollection mc = regex.Matches(myWeibo.Document.Body.InnerHtml);
                foreach (Match item in mc)
                {
                    //item.Value
                }
      

  4.   

    搞那么麻烦干嘛,你直接
    if(he.GetAttribute("data-follow")!=string.Empty)
    {
       //字符串处理
    }
    这样不就行了
      

  5.   


    高手,这样的标签应该怎么获取
    <li class=\"clearfix\" data-follow=\"uid=1821135665&fnick=梁博--\">
    我发现没斜杠的可以获取,但是带斜杠的就获取不到了