Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
wipiano committed Nov 22, 2024
1 parent d2d91be commit 5481d6f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion docs/core/whats-new/snippets/dotnet-9/csharp/Collections.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,9 @@ private static Dictionary<string, int> CountWords(ReadOnlySpan<char> input)
Dictionary<string, int>.AlternateLookup<ReadOnlySpan<char>> spanLookup =
wordCounts.GetAlternateLookup<ReadOnlySpan<char>>();

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<char> word = input[wordRange];
spanLookup[word] = spanLookup.TryGetValue(word, out int count) ? count + 1 : 1;
}
Expand Down

0 comments on commit 5481d6f

Please sign in to comment.