I’m very excited to announce the 1.0.0 release of the stringr package. If you haven’t heard of stringr before, it makes string manipulation easier by:

To get started with stringr, check out the new vignette.

What’s new?

The biggest change in this release is that stringr is now powered by the stringi package instead of base R. This has two big benefits: stringr is now much faster, and has much better unicode support.

If you’ve used stringi before, you might wonder why stringr is still necessary: stringi does everything that stringr does, and much much more. There are two reasons that I think stringr is still important:

  1. Lots of people use it already, so this update will give many people a performance boost for free.

  2. The smaller API of stringr makes it a little easier to learn.

That said, once you’ve learned stringr, using stringi should be easy, so it’s a great place to start if you need a tool that doesn’t exist in stringr.

New features and functions

x <- c("abc", "def")
str_replace_all(x, c("[ad]" = "!", "[cf]" = "?"))
#> [1] "!b?" "!e?"
x <- c("abc", "def", "jhi", "klm", "nop")
str_subset(x, "[aeiou]")
#> [1] "abc" "def" "jhi" "nop"
# The vowels come before the consonants in Hawaiian
str_sort(letters[1:10], locale = "haw")
#>  [1] "a" "e" "i" "b" "c" "d" "f" "g" "h" "j"
words <- c("These are   some words. Some more words.")
str_count(words, boundary("word"))
#> [1] 7
str_split(words, boundary("word"))
#> [[1]]
#> [1] "These" "are"   "some"  "words" "Some"  "more"  "words"

There were two minor changes to make stringr a little more consistent:


Stringr is over five years old and is quite stable (the last release was over two years ago). Although I’ve endeavoured to make the change to stringi as seemless as possible, it’s likely that it has created some new bugs. If you have problems, please try the development version, and if that doesn’t help, file an issue on github.