The code below...Gives me following resultCode:string sInput = @"from 2010 to 2011"; Regex reg1 = new Regex(@"\d+"); Regex reg2 = new Regex(@"(\d+)"); Match m = reg1.Match(sInput); Console.WriteLine(sInput); Console.WriteLine("Regex 1 groups ..."); foreach (Group g in m.Groups) { Console.WriteLine(g.ToString()); } m = reg2.Match(sInput); Console.WriteLine("Regex 2 groups ..."); foreach (Group g in m.Groups) { Console.WriteLine(g.ToString()); }Can anyone explain to me why for the first regex I'm only getting 2010 and why for the second regex I'm getting 2010 twice ?Code:from 2010 to 2011 Regex 1 groups ... 2010 Regex 2 groups ... 2010 2010




Reply With Quote