diff --git a/docs/core/whats-new/snippets/dotnet-9/csharp/Collections.cs b/docs/core/whats-new/snippets/dotnet-9/csharp/Collections.cs index 75769bf172996..838e11208dd0f 100644 --- a/docs/core/whats-new/snippets/dotnet-9/csharp/Collections.cs +++ b/docs/core/whats-new/snippets/dotnet-9/csharp/Collections.cs @@ -64,8 +64,9 @@ private static Dictionary CountWords(ReadOnlySpan input) Dictionary.AlternateLookup> spanLookup = wordCounts.GetAlternateLookup>(); - foreach (Range wordRange in Regex.EnumerateSplits(input, @"\b\w+\b")) + foreach (ValueMatch match in Regex.EnumerateMatches(input, @"\b\w+\b")) { + Range wordRange = match.Index..(match.Index + match.Length); ReadOnlySpan word = input[wordRange]; spanLookup[word] = spanLookup.TryGetValue(word, out int count) ? count + 1 : 1; }