<a href="http://www.microsoft.com/downloads/details.aspx?displaylang=zh-cn&FamilyID=211a9c07-88ff-4ae4-a82a-ce2045c6c4fe" target="_blank">下载此更新其中211a9c07-88ff-4ae4-a82a-ce2045c6c4fe可变,就求这个表达式
立即结贴

解决方案 »

  1.   

    string yourStr = ......;
    MatchCollection mc = Regex.Matches(yourStr, "<a\\s+href=\".+?&FamilyID=(.+?)\".+?>", RegexOptions.IgnoreCase);
    foreach(Match m in mc)
    {
        m.Groups[1].Value;//
    }
      

  2.   


    using System;
    using System.Runtime.InteropServices;
    using System.Text.RegularExpressions;namespace RegexTest
    {
        public class RegexTest
        {
            public void Test()
            {
                string input = @"<a href=""http://www.microsoft.com/downloads/details.aspx?displaylang=zh-cn&FamilyID=211a9c07-88ff-4ae4-a82a-ce2045c6c4fe"" target=""_blank"">下载此更新";            string pattern = @"(?<=&FamilyID=)[a-zA-Z0-9-]{36}(?=" target=)";
                RegexOptions options = RegexOptions.None;
                Regex regex = new Regex(pattern, options);
                MatchCollection matches = regex.Matches(input);            foreach (Match match in matches)
                {
                    Console.WriteLine(match.Value);
                }
            }
        }
    }
      

  3.   


    using System;
    using System.Runtime.InteropServices;
    using System.Text.RegularExpressions;namespace RegexTest
    {
        public class RegexTest
        {
            public static void Main()
            {
                string input = @"<a href=""http://www.microsoft.com/downloads/details.aspx?displaylang=zh-cn&FamilyID=211a9c07-88ff-4ae4-a82a-ce2045c6c4fe"" target=""_blank"">下载此更新";            string pattern = @"(?<=&FamilyID=)[a-zA-Z0-9-]{36}(?="" target=)";
                RegexOptions options = RegexOptions.None;
                Regex regex = new Regex(pattern, options);
                MatchCollection matches = regex.Matches(input);            foreach (Match match in matches)
                {
                    Console.WriteLine(match.Value);
                }
            }
        }
    }
      

  4.   

    string sid = "";
        string yourStr = "<a href=\"http://www.microsoft.com/downloads/details.aspx?displaylang=zh-cn&FamilyID=211a9c07-88ff-4ae4-a82a-ce2045c6c4fe\" target=\"_blank\">......;"
        Match mc = Regex.Matche(yourStr, "<a\\s+href=\"(?<URL>.+)&FamilyID=(?<name>.+)\">"\s+target=\"_blank\">......;", 
                                 RegexOptions.IgnoreCase);
        if(mc == null)
        {}
        else
        {
           sid =  m.Groups["name"].Value;//
        }
      

  5.   


    string strReg = "<a href=\"http://www.microsoft.com/downloads/details.aspx?displaylang=zh-cn&FamilyID=211a9c07-88ff-4ae4-a82a-ce2045c6c4fe\" target=\"_blank\">";strReg = Regex.Replace(strReg,@"<a\s+href=.*FamilyID=(?<a>[^\"]*?)\"\s+target=\"_blank\">", ${a},RegexOptions.IgnoreCase | RegexOptions.Compiled);可得到211a9c07-88ff-4ae4-a82a-ce2045c6c4fe