public static IEnumerable <GroupNode> GetSamples(Int32 count, Int32 captureCount) { if (01 <= count) { yield return(new GroupNode("Group # 1", true, 0, "0", CaptureNode.GetSamples(captureCount))); } if (02 <= count) { yield return(new GroupNode("Group # 2", true, 1, "1", CaptureNode.GetSamples(0))); } if (03 <= count) { yield return(new GroupNode("Group # 3", true, 2, "2", CaptureNode.GetSamples(0))); } if (04 <= count) { yield return(new GroupNode("Group # 4", false, 3, "3", CaptureNode.GetSamples(0))); } if (05 <= count) { yield return(new GroupNode("Group # 5", false, 4, "4", CaptureNode.GetSamples(0))); } if (06 <= count) { yield return(new GroupNode("Group # 6", false, 5, "5", CaptureNode.GetSamples(0))); } if (07 <= count) { yield return(new GroupNode("", true, 6, "6", CaptureNode.GetSamples(0))); } if (08 <= count) { yield return(new GroupNode("", true, 7, "7", CaptureNode.GetSamples(0))); } if (09 <= count) { yield return(new GroupNode("", true, 8, "8", CaptureNode.GetSamples(0))); } if (10 <= count) { yield return(new GroupNode("", false, 09, "9", CaptureNode.GetSamples(0))); } if (11 <= count) { yield return(new GroupNode("", false, 10, "10", CaptureNode.GetSamples(0))); } if (12 <= count) { yield return(new GroupNode("", false, 11, "11", CaptureNode.GetSamples(0))); } }
static void ExecuteMatch(IOptions snapshot, ResultsViewModel results) { var regex = snapshot.CreateRegex(1000); var groupNames = regex.GetGroupNames(); var groupNumbers = regex.GetGroupNumbers(); #region build tree if (snapshot.MultilineInput) { var checker = new Checker(SanityLimit, 5000); var nodes = new List <LineNode>(); var lines = Line.Split(snapshot.InputText); for (var i = 0; i < lines.Length; i++) { if (checker.Terminated) { break; } var line = lines[i]; var lineNode = new LineNode(line, i); nodes.Add(lineNode); checker.Adjust(); var match = regex.Match(snapshot.InputText, line.Index, line.Length); if (match.Success) { for (var j = 0; match.Success; j++, match = match.NextMatch()) { if (checker.Terminated) { break; } var matchNode = new MatchNode(match, j); ((IList <MatchNode>)lineNode.Matches).Add(matchNode); checker.Adjust(); for (var k = 0; k < groupNames.Length; k++) { if (checker.Terminated) { break; } var number = groupNumbers[k]; var name = groupNames[k]; var group = match.Groups[number]; var groupNode = new GroupNode(group, k, number, name); ((IList <GroupNode>)matchNode.Groups).Add(groupNode); checker.Adjust(); for (var l = 0; l < group.Captures.Count; l++) { if (checker.Terminated) { break; } var capture = group.Captures[l]; var captureNode = new CaptureNode(capture, l); ((IList <CaptureNode>)groupNode.Captures).Add(captureNode); checker.Adjust(); } } } } else { var matchNode = new MatchNode(match, 0); ((IList <MatchNode>)lineNode.Matches).Add(matchNode); checker.Adjust(); } } results.SetTree(nodes, checker.State); } else { var checker = new Checker(SanityLimit, 5000); var nodes = new List <MatchNode>(); var match = regex.Match(snapshot.InputText); if (match.Success) { for (var j = 0; match.Success; j++, match = match.NextMatch()) { if (checker.Terminated) { break; } var matchNode = new MatchNode(match, j); nodes.Add(matchNode); checker.Adjust(); for (var k = 0; k < groupNames.Length; k++) { if (checker.Terminated) { break; } var number = groupNumbers[k]; var name = groupNames[k]; var group = match.Groups[number]; var groupNode = new GroupNode(group, k, number, name); ((IList <GroupNode>)matchNode.Groups).Add(groupNode); checker.Adjust(); for (var l = 0; l < group.Captures.Count; l++) { if (checker.Terminated) { break; } var capture = group.Captures[l]; var captureNode = new CaptureNode(capture, l); ((IList <CaptureNode>)groupNode.Captures).Add(captureNode); checker.Adjust(); } } } } else { var matchNode = new MatchNode(match, 0); nodes.Add(matchNode); checker.Adjust(); } results.SetTree(nodes, checker.State); } #endregion }