Regular expressions (regex) are a powerful method for describing complex patterns in strings allowing the user to perform more specific tasks when processing string data. Regular expressions comprise a pattern-matching language R can use to parse strings based on complex criteria. However, it is important to note that regular expressions can be difficult to work with. We would recommend using a regular expression tester to check patterns before attempting to run regex in R.
This Regular Expression Tester (regexr) will help you efficiently test your regular expressions in R.
This guide on Matching Patterns with Regular Expressions contains great examples of how to use regular expressions with R.
This tutorial from the official R developers on Regular Expressions includes a careful breakdown of regex syntax.
This Cheat Sheet is a good reference for regular expression syntax.