Skip to content

Conversation

@danielparks
Copy link
Contributor

Note that a couple of existing tests (split2 and split3) were passing incorrectly before these changes.

I’m using /-/ as a short hand for Regex::new("-").unwrap(). It seems clear enough, but then I’ve written a lot of code in languages with regex literals.

This supersedes PR #606 which attempted to fix #521.

I disclaim ownership of these changes. They are owned by whoever owns the bulk of the rest of the code. (I am not a lawyer, but I’ll head them off at the pass if I can.)

Corrects `/-/.split("a-")` to return `["a", ""]` correctly 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.
Corrects `/-/.splitn("a", 2)` to return `["a"]` correctly instead of
`["a", ""]`. (`/-/` is shorthand for `Regex::new("-").unwrap()`.)
@danielparks danielparks mentioned this pull request Nov 18, 2019
@danielparks
Copy link
Contributor Author

The CI failure is only for Rust “stable.” It appears to be unrelated to the changes in this PR. https://travis-ci.com/rust-lang/regex/jobs/257680677

@danielparks
Copy link
Contributor Author

CI failure issue #634

BurntSushi pushed a commit that referenced this pull request 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 pull request 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 BurntSushi closed this in 65d6bba Jan 9, 2020
@danielparks danielparks deleted the split_627_and_521 branch January 11, 2020 10:57
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 this pull request may close these issues.

splitn(.., 2) returning extra substring

1 participant