Software
stringr

stringr

A fresh approach to string manipulation in R

R

stringr is an R package that provides a cohesive set of functions for working with strings, built on top of the stringi package which uses the ICU C library for fast, correct string manipulation. It focuses on the most common string operations with a consistent interface where all functions start with str_ and take a vector of strings as the first argument.

The package simplifies string manipulation through consistent function naming and behavior that works well with pipes and tidyverse workflows. It provides seven main pattern-matching verbs (detect, count, subset, locate, extract, match, replace, split) that work with regular expressions by default, plus support for fixed bytes, human letter collation, and boundary matching. Compared to base R string functions, stringr offers more predictable behavior where missing inputs produce missing outputs and zero-length inputs produce zero-length outputs.

Contributors

Resources using stringr