using System;
using System.Text.RegularExpressions;
class Example
{
staticvoid Main()
{
string text = "this is is is a test.";
string pat = @"(\w+)\s+(is)";
Regex r = new Regex(pat, RegexOptions.IgnoreCase);
Match m = r.Match(text);
int matchCount = 0;
while (m.Success)
{
for (int i = 1; i <= 2; i++)
{
Group g = m.Groups[i];
Console.WriteLine("Group"+i+"='" + g + "'");
CaptureCollection cc = g.Captures;
for (int j = 0; j < cc.Count; j++)
{
Capture c = cc[j];
System.Console.WriteLine("Capture"+j+"='" + c + "', Position="+c.Index);
}
}
m = m.NextMatch();
}
}
}