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

ignore_case doesn't work for str_replace_all when using named vector #207

alanault opened this Issue Jan 12, 2018 · 0 comments


None yet
2 participants

alanault commented Jan 12, 2018


I'm using str_replace_all with a named vector of patterns and replacements, so that they're all applied to a single character vector.

However, the ignore_case = TRUE argument seems to not have any effect:

# patterns and replacement
a <- c(apples = "fruit", pears = "fruit")

# test strings
test1 <- c("apples", "pears")
test2 <- c("APPLES", "PEARS")

# works; but doesn't need to ignore case
stringr::str_replace_all(test1, stringr::regex(a, ignore_case = TRUE))

# doesn't work 
stringr::str_replace_all(test2, stringr::regex(a, ignore_case = TRUE))

Is the ignore_case argument not meant to work when using a named vector, or is there another way I should be calling this?

many thanks

@hadley hadley added the bug label May 8, 2018

@hadley hadley closed this in 98b4fa8 May 8, 2018

calpan added a commit to calpan/stringr that referenced this issue Aug 1, 2018

Sync from parent (#1)
* Fix typo in regular expressions vignette (tidyverse#228)

Fixed typo that `[\^]` matches `^` and not `\`. Also changed order to be consistent with presentation in regexp.

* Add detail to boundary() documentation (tidyverse#230)

* Clean roxygen doc in str_glue and vignette (tidyverse#205)

* params correctly inherited by glue::glue_data below

* spelling typo in release 1.2.0 article

* reflow comment in str_c description

* Update docs

* Update stringi and corresponding test

* Require latest glue

Fixes tidyverse#237

* Fixed bug where str_trunc only worked on first vector element (tidyverse#206)

* Update news for tidyverse#206

* Respect modifiers of named vectors

Fixes tidyverse#207

* Fix typo

* str_replace can't replace boundaries

Fixes tidyverse#210

* Replace NAs in str_view

Fixes tidyverse#217

* Factor out common widget creation

* Tweak sizing policy

Fixes tidyverse#232

* Add life cycle badge

* Add thumbnail of cheat sheet (tidyverse#239)

* Add cheat sheet thumbnail

* Add thumbnail to end of usage section.
* Fixes tidyverse#219

* Tweak cheatsheet images

* Tweak news ordering

* Role needed stringi back to 1.1.7

* Run revdeps

* Add new cheat sheet thumbnail. (tidyverse#241)

* Remove old image file from package.

* Move cheatsheet to new location

* Bump version

* Submit to CRAN

* Update site
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment