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

string.Split not working as expected when using multiple string separators and StringSplitOptions.TrimEntries #73194

Closed
ccamposh opened this issue Aug 1, 2022 · 3 comments · Fixed by #73234
Assignees
Milestone

Comments

@ccamposh
Copy link

ccamposh commented Aug 1, 2022

Description

Considering these next C# code snippets results is the trimmed string "text",
" text ".Split(',', StringSplitOptions.TrimEntries)
" text ".Split(",", StringSplitOptions.TrimEntries)
" text ".Split(new char[] {','}, StringSplitOptions.TrimEntries)

This next code should have the same result:
" text ".Split(new string[] {","}, StringSplitOptions.TrimEntries)
The result of this last call is " text ", not trimmed.

Configuration

Dotnet version 6.0.100
OS: MacOs BigSur 11.4
Architecture: x64

Regression?

Not verified in previous versions

@jplonghi
Copy link

jplonghi commented Aug 1, 2022

@mairaw mairaw transferred this issue from dotnet/core Aug 1, 2022
@dotnet-issue-labeler
Copy link

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

@ghost ghost added the untriaged New issue has not been triaged by the area owner label Aug 1, 2022
@ghost
Copy link

ghost commented Aug 2, 2022

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

Issue Details

Description

Considering these next C# code snippets results is the trimmed string "text",
" text ".Split(',', StringSplitOptions.TrimEntries)
" text ".Split(",", StringSplitOptions.TrimEntries)
" text ".Split(new char[] {','}, StringSplitOptions.TrimEntries)

This next code should have the same result:
" text ".Split(new string[] {","}, StringSplitOptions.TrimEntries)
The result of this last call is " text ", not trimmed.

Configuration

Dotnet version 6.0.100
OS: MacOs BigSur 11.4
Architecture: x64

Regression?

Not verified in previous versions

Author: ccamposh
Assignees: -
Labels:

area-System.Runtime, untriaged

Milestone: -

@stephentoub stephentoub self-assigned this Aug 2, 2022
@stephentoub stephentoub added this to the 7.0.0 milestone Aug 2, 2022
@stephentoub stephentoub added bug and removed untriaged New issue has not been triaged by the area owner labels Aug 2, 2022
@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Aug 2, 2022
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Aug 5, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Sep 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants