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

str_view(), repetition at most n times yields error #807

Closed
vanderlindenma opened this issue Oct 2, 2019 · 1 comment
Closed

str_view(), repetition at most n times yields error #807

vanderlindenma opened this issue Oct 2, 2019 · 1 comment

Comments

@vanderlindenma
Copy link
Contributor

vanderlindenma commented Oct 2, 2019

* `{,m}`: at most m

As I was writing lecture notes based on the "strings" chapter, I stumbled upon the exact same issue as described in this Reddit thread: https://www.reddit.com/r/rprogramming/comments/8oyy1a/stringr_str_view_repetition_at_most_n_times/

On my end, it looked like this. The intention was to show that there would be no match in this case. Instead, I get an error:

str_view_all("Misery, Misery, Misery that’s what Lord and Miller have chosen", "(Misery, ){,3}")

Error in stri_locate_all_regex(string, pattern, omit_no_match = TRUE, : Error in {min,max} interval. (U_REGEX_BAD_INTERVAL)

One of the answerers on Reddit explains:

"stringr uses ICU regular expressions, which apparently do not have the {,m} notation - use the explicit {n,m}."

Since the {,m} "method" is presented as a viable option in the latest version of the book and I did not see an open issue related to this, I thought I'd mention it here.

Perhaps the error message when using {,m} is clear enough and the inclusion of {,m} in the book is intentional (in the sense that it discusses a valid regex, albeit one that does not work with stingr, and is judiciously not included in the examples of stingr applications)?

mine-cetinkaya-rundel added a commit that referenced this issue Apr 14, 2021
…ypos in "Iteration chapter" (#808)

* Update and rename strings.Rmd to strings.Rmd 

Proposed fix related to this issue: #807

A more comprehensive fix should perhaps discuss why "`{,m}`: at most m" does not work (or warn the reader that it does not)

* Typos in iteration.Rmd

Correcting two small typos

* Add missing word

* Add code example for 1,m

Co-authored-by: Mine Cetinkaya-Rundel <cetinkaya.mine@gmail.com>
@hadley hadley closed this as completed Apr 18, 2021
@hadley
Copy link
Owner

hadley commented Apr 18, 2021

This is fixed in the 2nd ed.

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