Regular Expressions Basics
In this Regular Expression Basics mission, you will learn what regular expressions (regex) are and how you can use them to do some advanced data cleaning in R.
We’ll cover the fundamentals of regular expressions and how they can be used for more powerful string manipulation. You’ll learn about regex concepts such as character classes, quantifiers, capture groups, positional anchors, and more. Then you’ll learn about how to make use of regular expressions in R using the
stringr package. This module allows you to easily perform regex operations like searching and replacing text patterns with other text patterns directly in your R code.
In this mission, you will be working with text data from Hacker News, which will give you plenty of practice using regular expressions to tidy up messy text for analysis. You’ll get the opportunity to think like a data scientist as you explore this data set, and by the end of the mission, you will have a working knowledge of regular expressions and how to use them to do powerful string manipulation.
In addition to this mission, you can also check out our Regular Expressions tutorial for extra practice or as a supplementary learning resource!
- Learn what regular expressions are and how to use them.
- Learn regex compnents like character classes and quantifiers.
- Learn how to use Regular Expressions with the stringr package
- The Regular Expression Functions in R
- Set of Characters in Regular Expressions
- Alternative Patterns
- Using Regular Expressions to Select Data
- Character Classes
- Accessing the Matching Text with Capture Groups
- Negative Character Classes
- Word Boundaries
- Matching at the Start and End of Strings
- Challenge: Using Flags to Modify Regex Patterns
- Next Steps