我要把1=1 || ("ss".substring(1,3)="1") &&2!=2 , (select f1,f2,f2 from tb1),(select f1,f_2,f3 from tb where e in (1,3,4,5))
拆分成
1=1 || ("ss".substring(1,3)="1") &&2!=2 
(select f1,f2,f2 from tb1)
(select f1,f_2,f3 from tb where e in (1,3,4,5))
就是把逗号隔开的逻辑表达式,sql语句1,sql语句2分开
怎么才能做到

解决方案 »

  1.   

    [^,\(\)]*(((?<o>\()[^\(\)]*)+((?<-o>\))[^,\(\)]*)+)*[^,\(\)]*(?=,|$)试试看不过,可能会有一些情况考虑得不是那么周全。。
      

  2.   

    就是把逗号隔开的三个字符串分开,如果字符串中有逗号则必须用括号括起来
    比如:
    CurDate=="20080801" , (select f1,f2,f2 from tb1),select * from tb2 
    拆分成,
    字符串1: CurDate=="20080801" 
    字符串2: (select f1,f2,f2 from tb1)
    字符串3: select * from tb2 再比如:
    1=1 || ("ss".substring(1,3)="1") &&2!=2 , (select f1,f2,f2 from tb1),(select f1,f_2,f3 from tb where e in (1,3,4,5)) 
    拆分成,
    字符串1:  1=1 || ("ss".substring(1,3)="1") &&2!=2
    字符串2: (select f1,f2,f2 from tb1)
    字符串3: (select f1,f_2,f3 from tb where e in (1,3,4,5)) 
      

  3.   

    考虑到""中可能也会出现“,”,加了一个判断MatchCollection mc = Regex.Matches(str, @"[^()"",]*((""[^""]*""|\(((?>\((?<o>)|\)(?<-o>)|.)*)(?(o)(?!))\))[^()"",]*)+|[^()"",]+");
    foreach (Match m in mc)
    {
        Console.WriteLine(m.Value);
    }
    Console.ReadLine();
      

  4.   

    min_jie的对
    root_ 的不行