/// <summary>
///
/// </summary>
/// <param name="source"></param>
/// <param name="matchPattern"></param>
/// <param name="wantInitialMatch"></param>
/// <returns></returns>
public static ArrayList ExtractGroupings(string source, string matchPattern, bool wantInitialMatch)
{
ArrayList keyedMatches = new ArrayList();
int startingElement = 1;
if (wantInitialMatch)
{
startingElement = 0;
}
Regex RE = new Regex(matchPattern, RegexOptions.Multiline);
MatchCollection theMatches = RE.Matches(source);
foreach (Match m in theMatches)
{
Hashtable groupings = new Hashtable();
for (int counter = startingElement;
counter < m.Groups.Count; counter++)
{
// If we had just returned the MatchCollection directly, the
// GroupNameFromNumber method would not be available to use
groupings.Add(RE.GroupNameFromNumber(counter),
m.Groups[counter]);
}
keyedMatches.Add(groupings);
}
return (keyedMatches);
}