Regex Challenge!
Welcome to the "Regex Challenge" lesson! In this exciting lesson, we'll put your Regex skills to the test by tackling two challenging problems. Each problem will require you to apply the concepts and techniques learned in the previous lessons to construct complex Regex patterns and solve real-world scenarios. Let's dive in and sharpen your Regex prowess!
Throughout this lesson, you'll encounter a variety of problem scenarios that require different Regex patterns to solve. For each problem, you'll be provided with a description and an example string. Your task is to design a Regex pattern that matches the desired pattern or extracts specific information from the given string.
Challenge #1:
You are given a list of email addresses. Your task is to extract all the unique domain names from the string of emails. Copy the code below into the Python IDE and update the pattern variable so that it outputs all of the domain names in the string.
The output should be as shown below:
{'example.net', 'example.com'}
If you get stuck, you can check out the solution below:
Challenge #1 Solution
pattern = "@(.*)"
Challenge #2:
Your objective is to extract all the hashtags from a given tweet. Copy the code below into the Python IDE and update the pattern variable so that it outputs all of the hashtags in the string.
No comments yet. Add the first comment to start the discussion.