本帖最后由 aloneone 于 2013-11-13 23:36:55 编辑

解决方案 »

  1.   

    这代码写的够乱的,挺简单一事让你搞复杂了:  string text = "select * from blue order by a";
    string pat = @"(?:select)|(?:from)|(?:order)|(?:by)";
    // Compile the regular expression.
    Regex r = new Regex(pat, RegexOptions.IgnoreCase);

    foreach(Match m in r.Matches(text))
    {
      foreach(Capture c in m.Captures)
       Console.WriteLine(c.Value);
    }
      

  2.   

     for (int i = 1; i <= 2; i++)为什么是<=2呢? 那不是只能显示2组吗?  加 上order by 不是有4组.