也许不是能让人满意的答案:         string str = "(name='abc') and (id>123) or (memo like '%(v)%')";
string[] sList = System.Text.RegularExpressions.Regex.Split(str,@"\) ");

for (int i=0; i < sList.Length; i++)
{
if (!sList[i].EndsWith(")"))
sList[i] +=")";
Console.WriteLine("{0}:{1}", i, sList[i]);
}

解决方案 »

  1.   

    试试using System;
    using System.Text.RegularExpressions;string str = "(name='abc') and (id>123) or (memo like '%(v)%')";
    Regex re =  new Regex(@"\s*((\w+\s*)?\([^\(\)]+(\([^\)]*\))*[^\)]*\))");
    MatchCollection mc = re.Matches(str);
    for (int i=0; i < mc.Count; i++)
    {
    Console.WriteLine("{0}:***{1}***",i, mc[i].Result("$1"));
    }