Incorrect code sample in Collection lookups with spans documentation #43701
Labels
dotnet-fundamentals/svc
in-pr
This issue will be closed (fixed) by an active pull request.
Pri1
High priority, do before Pri2 and Pri3
⌚ Not Triaged
Not triaged
Type of issue
Code doesn't work
Description
In the current documentation, there's a code sample that doesn't work as intended. The issue is in the following method:
The problem is that
Regex.EnumerateSplits
is used to iterate over the input, but this method enumerates the separators between words, not the words themselves.I believe the correct implementation should use
Regex.EnumerateMatches
instead, like this:This change ensures that the method correctly iterates over the words in the input, rather than the spaces between them.
Page URL
https://learn.microsoft.com/en-us/dotnet/core/whats-new/dotnet-9/libraries#collection-lookups-with-spans
Content source URL
https://github.com/dotnet/docs/blob/main/docs/core/whats-new/dotnet-9/libraries.md
Document Version Independent Id
0c8c7059-86a1-e5df-32e6-fae6fdc5cae0
Article author
@gewarren
Metadata
Related Issues
The text was updated successfully, but these errors were encountered: