Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
- Reading Files 7:00
- Basics 4 questions
- The Basics 5 objectives
- Escape Hatches 5:23
- Escapes 4 questions
- Escapes 2 objectives
- Counts 6:05
- Phone Numbers 1 objective
- Word Length 1 objective
- Sets 5:42
- Email 1 objective
- Negation 8:20
- Negated Numbers 1 objective
- Groups 9:45
- Name Groups 1 objective
- Email Groups 2 objectives
- Compiling and Loops 6:51
- Players Dictionary and Class 2 objectives
- Review: Regular Expressions in Python 8 questions
Start a free Courses trial
to watch this video
- 2x 2x
- 1.75x 1.75x
- 1.5x 1.5x
- 1.25x 1.25x
- 1.1x 1.1x
- 1x 1x
- 0.75x 0.75x
- 0.5x 0.5x
Patterns, sets, groups, oh my! Now that we have so much control over what our patterns find and what we can create from the Match
es we get back, let's look at a way to turn regular expressions into a variable and then loop over our results.
New terms
-
re.compile(pattern, flags)
- method to pre-compile and save a regular expression pattern, and any associated flags, for later use. -
.groupdict()
- method to generate a dictionary from aMatch
object's groups. The keys will be the group names. The values will be the results of the patterns in the group. -
re.finditer()
- method to generate an iterable from the non-overlapping matches of a regular expression. Very handy forfor
loops. -
.group()
- method to access the content of a group.0
or none is the entire match.1
through how ever many groups you have will get that group. Or use a group's name to get it if you're using named groups.
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up-
boi
14,242 PointsExtra credit submission
Posted by boiboi
14,242 Points0 Answers
-
zy93
Python Web Development Techdegree Student 6,879 Points0 Answers
-
ishakahmed
11,359 Points1 Answer
-
Mark Chesney
11,747 Points4 Answers
-
Tom Watson
9,987 Points1 Answer
-
Bijay Gurung
1,818 Points1 Answer
-
Flore W
4,744 PointsHas anyone done the Extra Credit? Can you share what you've done?
Posted by Flore WFlore W
4,744 Points1 Answer
-
V K
5,237 PointsI don't understand why < > was used around email in the following print statement
Posted by V KV K
5,237 Points1 Answer
-
Pavlo Kochubei
15,009 Points1 Answer
-
shibashis
8,989 Points1 Answer
-
igsm '
10,440 PointsBoolean with re?
Posted by igsm 'igsm '
10,440 Points3 Answers
-
Adiv Abramson
6,919 Points1 Answer
View all discussions for this video
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up