Advanced Regular Expressions
In this Advanced Regular Expressions with R mission, you will build on what you learned in the Regular Expressions Basics mission to expand your knowledge of string manipulation for advanced data cleaning tasks.
In this one, you’ll dive into regex techniques like lookarounds, backreferences, substitution, and more. As in the previous mission, you’ll make use of Python’s
stingr library to use regular expressions inside your Python code, doing things like searching for and replacing text patterns with other text patterns. In addition to the
stringr module, you’ll also learn to use string functions with regular expressions to get a better grasp of how regex fits into a typical data cleaning workflow.
In this mission, you will continue working real text data from Hacker News submissions, using your new regex skills to further clean the data set. Because you’ll be working with real-world data, you will get the opportunity to think like a data scientist, and by the end of this mission, you will have a solid grasp of regular expressions and how to use them to do powerful string manipulation using R and
- Learn to clean data by substituting regular expression matches.
- Use lookarounds to include and exclude text before/after your regex match.
- Learn to use capture groups to extract new columns from text data.
- Capture Groups
- Using Capture Groups to Extract Data
- Counting Mentions of the ‘C’ Language
- Using Lookarounds to Control Matches Based on Surrounding Text
- BackReferences: Using Capture Groups in a RegEx Pattern
- Challenge: Cleaning our dataset
- Substituting Regular Expression Matches
- Extracting Domains from URLs
- Extracting URL Parts Using Multiple Capture Groups
- Next Steps