Created
May 16, 2014 20:22
-
-
Save theredpea/18c542bb2d16d721ecbb to your computer and use it in GitHub Desktop.
GroupsVsCaptures
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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