Skip to content

Conversation

@carlganz
Copy link
Contributor

Apropos of this twitter thread here is small PR that updates detect helpers so that they honor regex "|" operator more intuitively. It doesn't break any existing tests, but I didn't run full revdepcheck because I don't want my computer to catch fire.

I'm sure there will be cases where somebody has code that depends on the previous functionality, but I feel pretty strongly that this change makes the API more intuitive.

NEWS.md Outdated
@@ -1,5 +1,7 @@
# stringr (development version)

* Update `str_starts()` and `str_ends()` functions so they honor regex "|" operator more intuitively. (@carlganz)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’d phrase this more generally - it’s about operator precedence in generally, not just |. Otherwise, looks great.

expect_true(str_starts("ab", regex("A", ignore_case = TRUE)))

# Or operators are respected
expect_true(str_starts("ab", regex("B|A", ignore_case = TRUE)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also I don’t think you should using ignore_case as that’s unrelated to this isse

@hadley hadley merged commit f70c4ba into tidyverse:master Jun 1, 2020
@hadley
Copy link
Member

hadley commented Jun 1, 2020

Thanks!

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.

2 participants