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:
Using consistent function and argument names: all functions start with
str_, and the first argument is always the input string This makes stringr easier to learn and easy to use with the pipe.
Eliminating options that you don’t need 95% of the time.
To get started with stringr, check out the new vignette.
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:
Lots of people use it already, so this update will give many people a performance boost for free.
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.
str_replace_all() gains a convenient syntax for applying multiple pairs of pattern and replacement to the same vector:
str_subset() keeps values that match a pattern:
boundary() allows you to count, locate and split by character, word, line and sentence boundaries.
There were two minor changes to make stringr a little more consistent:
str_c() now returns a zero length vector if any of its inputs are zero length vectors. This is consistent with all other functions, and standard R recycling rules. Similarly, using
str_c("x", NA) now yields
NA. If you want
str_replace_na() on the inputs.