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

FR: resolve incompatible pattern modification earlier #60

Closed
ctbrown opened this issue Mar 23, 2015 · 1 comment
Closed

FR: resolve incompatible pattern modification earlier #60

ctbrown opened this issue Mar 23, 2015 · 1 comment

Comments

@ctbrown
Copy link

ctbrown commented Mar 23, 2015

Please have incompatible search modifiers fixed vs perl / ignore.case be resolved at the call of these function and not defer to the str_* calls. Take the following example:

pattern <- 
  "str" %>%
  ignore.case %>%
  perl  # %>%
  # fixed -> pattern


str(pattern)
# Overriding Perl regexp matching
#  atomic [1:1] pattern
#  - attr(*, "ignore.case")= logi TRUE
#  - attr(*, "perl")= logi TRUE
#  - attr(*, "fixed")= logi TRUE

In this case, each of the match modifiers set an attribute to TRUE, though they are incompatible. If one were to examine pattern as is done in the example, the effects are unclear as they will be resolved later. A better method would have successive calls to the modifiers adjust pattern as appropriate. This can be done changing the functions. For example, fixed might become:

fixed <-   function(string) {
  if (stringr::is.perl(string)) 
    message("Overriding Perl regexp matching")
  structure(string, fixed = TRUE, perl = NULL, ignore.case = NULL )
}

Or perl = FALSE as another alternative.

@ctbrown ctbrown changed the title Feature request: resolve pattern modification functions earlier Feature request: resolve incompatible pattern modification earlier Mar 23, 2015
@ctbrown ctbrown changed the title Feature request: resolve incompatible pattern modification earlier FR: resolve incompatible pattern modification earlier Mar 23, 2015
@ctbrown
Copy link
Author

ctbrown commented Mar 30, 2015

This might not be relevant to the newer stringi based release.

@hadley hadley closed this as completed in 15a586a Oct 30, 2015
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

1 participant