如有字符串  string connectionString="server=xx;uid=xx;pwd=;database=xx"把"="和";"之间的4组 子串  截取出来 
求上面正则表达式!!! 谢谢

解决方案 »

  1.   

    Match m = Regex.Match("", "(?i)(?<=" + fieldname + "=)[^;]+(?=;|$)");
      

  2.   

    好像你们的方法只是获取了 第一组匹配的 子串,,可能我方法错误,求指教            string pattern = "(?<==).*?(?=;|$)";
                //pattern = "(?<==)[^;$]+";
                Regex rg = new Regex(pattern, RegexOptions.IgnoreCase | RegexOptions.Multiline | RegexOptions.Singleline);            Match m = rg.Match(str);
                string str1 = "";            foreach (Group col in m.Groups)
                {
                    str1 += col.Value + "   ";
                }
      

  3.   

    MatchCollection collection = rg.Matches(str);
    foreach(Match m in collection )
     console.writeline(m.Value);
      

  4.   

    Regex regs = new Regex(@"(?<==).*?(?=;|$)");
                string s = "server=xx;uid=xx;pwd=;database=xx";
    string ss="";
    MatchCollection mc = regs.Matches(s);
                foreach (Match m in mc)
                {
                    ss += m.Groups[0].Value.ToString();
                }