why regex return multi value for the match?
See the following code, it should only return one result. why there are two?
e.g
Match m = Regex.Match("[Red] #,0.00 \"Ex\"", @"^\[(RED|GREEN|ORANGE)\]", RegexOptions.IgnoreCase);
if (m.Success)
{
Console.WriteLine(m.Groups.Count);
Console.WriteLine(m.Groups[0].Value);
Console.WriteLine(m.Groups[1].Value);
}
else
Console.WriteLine("No match");
========Result===============
2
[Red]
Red
Press any key to continue . . .
There is a single match
m, which has a single capturing group.m.Groups[0]is always the entire match.m.Groups[1]is the first capture, etc..If you want to see all matches, you can do this: