这个正则表达式给出了计数的答案3。 在“你好”之前我怎么能只拿第一和第二“一些”? 请帮帮我。
string SomeText ="Some some hello some"
string patternSome = @"some";
RegexOptions RegOptions = RegexOptions.IgnoreCase |RegexOptions.CultureInvariant;
Regex newRegex = new Regex(patternSome, RegOptions );
MatchCollection matches = newRegex.Matches(SomeText);
Console.WriteLine("Count of matches {0}", matches.Count);