Skip to content

Instantly share code, notes, and snippets.

@theredpea
Created May 16, 2014 20:22
Show Gist options
  • Save theredpea/18c542bb2d16d721ecbb to your computer and use it in GitHub Desktop.
Save theredpea/18c542bb2d16d721ecbb to your computer and use it in GitHub Desktop.
GroupsVsCaptures
void Main()
{
///Understanding Captures vs Groups http://stackoverflow.com/a/3320890/1175496
//In short, Groups represent things inside Grouping Parentheses ()
//Captures represent the items in the collection implied by repetition operators * and +
var matchesONE = Regex.Matches("{Q}{R}{S}", @"(\{[A-Z]\})");
var matchesOOM = Regex.Matches("{Q}{R}{S}", @"(\{[A-Z]\})+");
var matchesOPT = Regex.Matches("{Q}{R}{S}", @"(\{[A-Z]\})*");
Console.Out.WriteLine(matchesONE);
Console.Out.WriteLine(matchesOOM);
Console.Out.WriteLine(matchesOPT);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment