Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[API Proposal]: System.String.RSplit #109583

Open
mikeronayne opened this issue Nov 6, 2024 · 3 comments
Open

[API Proposal]: System.String.RSplit #109583

mikeronayne opened this issue Nov 6, 2024 · 3 comments
Labels
api-suggestion Early API idea and discussion, it is NOT ready for implementation area-System.Runtime untriaged New issue has not been triaged by the area owner

Comments

@mikeronayne
Copy link

Background and motivation

Python exposes this as rsplit (tests showing behavior here).

Note that Python's maxsplit parameter has a bit different semantics than C#'s Split's count. C#'s RSplit should use C#'s Split's count semantics.

API Proposal

This should behave exactly like the System.String.Split overloads that accept count, except we start counting delimiters from the right instead of the left.

API Usage

"ABC-DEF-GHI".RSplit('-', count: 2) returns ["ABC-DEF", "GHI"]

Alternative Designs

Instead of adding a new RSplit method, I could see this also being implemented as a new StringSplitOptions.

Risks

No response

@mikeronayne mikeronayne added the api-suggestion Early API idea and discussion, it is NOT ready for implementation label Nov 6, 2024
@dotnet-issue-labeler dotnet-issue-labeler bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Nov 6, 2024
@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Nov 6, 2024
@MihaZupan MihaZupan added area-System.Runtime and removed needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners labels Nov 6, 2024
Copy link
Contributor

Tagging subscribers to this area: @dotnet/area-system-runtime
See info in area-owners.md if you want to be subscribed.

@teo-tsirpanis
Copy link
Contributor

Extending StringSplitOptions sounds like a better idea than adding a new method (which should be called something like SplitRight).

@MichalPetryka
Copy link
Contributor

SplitRight

Or SplitEnd.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-suggestion Early API idea and discussion, it is NOT ready for implementation area-System.Runtime untriaged New issue has not been triaged by the area owner
Projects
None yet
Development

No branches or pull requests

4 participants