使用GetResponse获得返回的String st后,
st中含有
<input type="hidden" name="ptk" id="ptk" value="554f6760343640a5b2ebdb80f2d3297d"/>
....
<input type="hidden" name="cd" id="cd" value="1490"/>如何提取出
554f6760343640a5b2ebdb80f2d3297d求代码!

解决方案 »

  1.   

    System.Text.RegularExpressions.MatchCollection mc =
        System.Text.RegularExpressions.Regex.Matches(
            st,
            @"<input\s+[^>]*name\s*=[""']ptk[""'][^>]*value\s*=[""'](?<url>.*?)[""'][^>]*/>",
            System.Text.RegularExpressions.RegexOptions.IgnoreCase
            | System.Text.RegularExpressions.RegexOptions.Singleline);foreach (System.Text.RegularExpressions.Match m in mc)
    {
        Console.WriteLine("value:{0}", m.Groups["url"].Value);
    }
      

  2.   


            public static string GetStartEndStr(string source, string start, string end)
            {
                string str = "";
                int len1 = source.IndexOf(start);
                if (len1 > -1)
                {
                    string cutstr = source.Substring(len1 + (start).Length);
                    int len2 = cutstr.IndexOf(end);
                    str = cutstr.Substring(0, len2);
                }
                return str;
            }GetStartEndStr(html, "id=\"ptk\" value=\"", "\"");
      

  3.   

    GetStartEndStr(html, "id=\"ptk\" value=\"", "\""); 在C#出现错误