How to write a simple regular expression with R using sub and str_replace (CC183)

January 31, 2022 • PD Schloss • 1 min read

A regular expression is a pattern that you want to search for and do something with. R has a variety of tools for creating regular expressions that allow you to maniuplate text. In this episode we’ll see the similarities and differences between sub and str_replace and how they differ from gsub and str_replace_all. We’ll introduce metacharacters and quantifiers. This is part of a series of videos demonstrating how to functions from base R to make these data compatible with tools from the tidyverse


You can browse the state of the repository at the