From 5481d6f7de44f14d43213a5f4e96c0f082fc72e4 Mon Sep 17 00:00:00 2001 From: Kohei Hakoishi Date: Fri, 22 Nov 2024 17:05:43 +0900 Subject: [PATCH] fix https://github.com/dotnet/docs/issues/43701 --- docs/core/whats-new/snippets/dotnet-9/csharp/Collections.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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; }