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

New str_view() does not fully replace old str_view() and deprecated str_view_all() #505

Closed
mgarbuzov opened this issue Mar 21, 2023 · 1 comment

Comments

@mgarbuzov
Copy link

mgarbuzov commented Mar 21, 2023

This change in the recent patch doesn't seem to do what it is intending to do.

From the changelog: It defaults to displaying all matches, making str_view_all() redundant (and hence deprecated) (#455).

It seems there's been a confusion between what a "match" is. Some people used it to mean a pattern within an element, and others a whole element of a vector.

For example, the match = NA argument here str_view(c("abc", "def", "fghi"), "e", match = NA) can be used to show all elements of a vector, whether they contain a matching pattern or not, but there is no longer a way to control whether only the first or all patterns within elements are matched. For example: str_view("defe", "e") returns all two matches of "e" - a behaviour equivalent to deprecated str_view_all(), but it's no longer possible to get the behaviour of the old str_view() where it would match only one first pattern.

The issue #455 cited in the changelog proposes controlling this with the argument all_matches, but this isn't implemented, which suggests the turning of new str_view() into str_view_all() and deprecating of str_view_all() were premature.

In light of this confusion, could the arguments match and all_matches be better named all_elements and all_patterns or something along those lines?

@mgarbuzov mgarbuzov changed the title New str_view() does not fully replace old str_view() and deprecated str_view_all()` New str_view() does not fully replace old str_view() and deprecated str_view_all() Mar 21, 2023
@hadley
Copy link
Member

hadley commented Aug 4, 2023

There's no way to control if all matches or just one match is displayed, but if you can see all matches you can also see the first match. I don't think just seeing the first match is that common, so I deliberately dropped this ability. Sorry if that was unclear from the docs/news.

@hadley hadley closed this as completed Aug 4, 2023
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

No branches or pull requests

2 participants