【发布时间】:2011-08-10 06:06:51
【问题描述】:
谁能解释为什么 Regex.Match 捕获非捕获组。在 MSDN 中找不到任何关于它的信息。为什么
Regex regexObj = new Regex("(?:a)");
Match matchResults = regexObj.Match("aa");
while (matchResults.Success)
{
foreach (Capture g in matchResults.Captures)
{
Console.WriteLine(g.Value);
}
matchResults = matchResults.NextMatch();
}
产生输出
a
a
而不是空的?
【问题讨论】: