本文整理汇总了C#中System.Text.RegularExpressions.Regex.Count方法的典型用法代码示例。如果您正苦于以下问题:C# Regex.Count方法的具体用法?C# Regex.Count怎么用?C# Regex.Count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Text.RegularExpressions.Regex
的用法示例。
在下文中一共展示了Regex.Count方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateNames
private IEnumerable<string> GenerateNames(int ruleNum, string nameFormat, int currentChannel, int totalChannels)
{
var resultingNames = new List<string>();
if (lbRules.Items.Count < ruleNum || currentChannel > totalChannels) {
return resultingNames;
}
var ruleEngine = _ruleEngines[ruleNum - 1];
if (ruleEngine.Iterations != 0) {
var generatedNames = new List<string>(ruleEngine.GenerateNames());
for (var i = 0; (i < ruleEngine.Iterations || ruleEngine.IsUnlimited) && currentChannel + resultingNames.Count < totalChannels; i++) {
var parts = new Regex("{" + (ruleNum - 1) + "[:]?[a-zA-Z0-9]*}").Match(nameFormat).ToString().Split(':');
var format = parts.Count() == 2 ? "{0:" + parts[1] : "{0}";
var replace = parts.Count() == 2 ? "{" + (ruleNum - 1) + ":" + parts[1] : "{" + (ruleNum - 1) + "}";
var replacementValue = ruleEngine.IsUnlimited ? ruleEngine.GenerateName(i) : generatedNames[i];
int numericReplacement;
var formattingResult = nameFormat.Replace(replace,
int.TryParse(replacementValue, out numericReplacement) ? string.Format(format, numericReplacement) : replacementValue);
// Is this the last rule?
if (ruleNum >= _ruleEngines.Count) {
resultingNames.Add(formattingResult);
}
else {
resultingNames.AddRange(
GenerateNames(ruleNum + 1, formattingResult, currentChannel + resultingNames.Count, totalChannels).ToList());
}
}
}
else {
resultingNames.Add(ruleEngine.GenerateDefaultName());
}
return resultingNames;
}