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

splitn(.., 2) returning extra substring #521

Closed
casey opened this issue Oct 8, 2018 · 0 comments
Closed

splitn(.., 2) returning extra substring #521

casey opened this issue Oct 8, 2018 · 0 comments

Comments

@casey
Copy link

casey commented Oct 8, 2018

I'm seeing an extra substring produced by splitn in this code.

I'd expect splitn(1), splitn(2), and splitn(3) to produce the same output, but splitn is returning an extra empty substring.

BurntSushi pushed a commit that referenced this issue Jan 9, 2020
Corrects `/-/.split("a-")` to return `["a", ""]` instead of `["a"]`.
(`/-/` is shorthand for `Regex::new("-").unwrap()`.)

This adds tests for both `split()` and `splitn()` covering a variety of
edge cases. One test is commented out because it is failing due to #521.
A future commit will fix it.

Note that the `split2` and `split3` tests were passing incorrectly
before this change. I have fixed them to expect the correct values.

Fixes #627
BurntSushi pushed a commit that referenced this issue Jan 9, 2020
Corrects `/-/.splitn("a", 2)` to return `["a"]` instead of `["a", ""]`.
(`/-/` is shorthand for `Regex::new("-").unwrap()`.)

Fixes #521, Closes #606, Closes #628
BurntSushi pushed a commit that referenced this issue Jan 9, 2020
Corrects `/-/.splitn("a", 2)` to return `["a"]` instead of `["a", ""]`.
(`/-/` is shorthand for `Regex::new("-").unwrap()`.)

Fixes #521, Closes #606, Closes #628
BurntSushi pushed a commit that referenced this issue Jan 9, 2020
Corrects `/-/.split("a-")` to return `["a", ""]` instead of `["a"]`.
(`/-/` is shorthand for `Regex::new("-").unwrap()`.)

This adds tests for both `split()` and `splitn()` covering a variety of
edge cases. One test is commented out because it is failing due to #521.
A future commit will fix it.

Note that the `split2` and `split3` tests were passing incorrectly
before this change. I have fixed them to expect the correct values.

Fixes #627
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant