[API Proposal]: Regex.EnumerateSplits #100369
Labels
api-ready-for-review
API is ready for review, it is NOT ready for implementation
area-System.Text.RegularExpressions
Milestone
Background and motivation
In .NET 7, we added the EnumerateMatches methods to enable ammortized allocation-free support for matching. However, the Regex.Split method is handy for finding the gaps between matches, and using EnumerateMatches to achieve that is non-trivial; developers then use the more expensive Split.
API Proposal
API Usage
Alternative Designs
int count
are less important with EnumerateSplits, as a caller can always choose to stop iterating. However, they're included for two reasons: 1) to keep the overload shape the same with Split, so that someone calling theinput, count
overload switching to use EnumerateSplits doesn't implicitly start calling ainput, startat
overload, and 2) to keep the behavior the same for the last split, which when the count is smaller than the actual number will end up including all of the remainder of the input.Risks
No response
The text was updated successfully, but these errors were encountered: