Advanced Regular Expressions

In this Advanced Regular Expressions with Python 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 re module 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 re module, you'll also learn to use pandas 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 Python,  re, and pandas.


  • 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.

Mission Outline

1. Introduction
2. Capture Groups
3. Using Capture Groups to Extract Data
4. Counting Mentions of the 'C' Language
5. Using Lookarounds to Control Matches Based on Surrounding Text
6. BackReferences: Using Capture Groups in a RegEx Pattern
7. Substituting Regular Expression Matches
8. Extracting Domains from URLs
9. Extracting URL Parts Using Multiple Capture Groups
10. Using Named Capture Groups to Extract Data
11. Next Steps
12. Takeaways


Course Info:

Python Data Cleaning Advanced


The average completion time for this course is 6–8-hours.

This course requires a basic subscription and includes four missions. It is the sixth course in the Data Analyst in Python Path and Data Scientist in Python Path


Take a Look Inside