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

- 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
Exact matches are great but most of the time you'll be looking for more generic and general things. Let's talk about the escape sequences we have available in regular expressions that let us match conceptual things like whitespace and word boundaries.
New terms
-
\w
- matches an Unicode word character. That's any letter, uppercase or lowercase, numbers, and the underscore character. In "new-releases-204",\w
would match each of the letters in "new" and "releases" and the numbers 2, 0, and 4. It wouldn't match the hyphens. -
\W
- is the opposite to\w
and matches anything that isn't an Unicode word character. In "new-releases-204",\W
would only match the hyphens. -
\s
- matches whitespace, so spaces, tabs, newlines, etc. -
\S
- matches everything that isn't whitespace. -
\d
- is how we match any number from 0 to 9 -
\D
- matches anything that isn't a number. -
\b
- matches word boundaries. What's a word boundary? It's the edges of word, defined by white space or the edges of the string. -
\B
- matches anything that isn't the edges of a word.
Two other escape characters that we didn't cover in the video are \A
and \Z
. These match the beginning and the end of the string, respectively. As we'll learn later, though, ^
and $
are more commonly used and usually what you actually want.
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up-
Johnny Austen
Front End Web Development Techdegree Graduate 35,494 Points1 Answer
-
awake
6,126 Points1 Answer
-
harmeet
698 Points1 Answer
-
harmeet
698 Points1 Answer
-
Sahar Nasiri
7,454 Points1 Answer
-
Sahar Nasiri
7,454 Points1 Answer
-
James N
17,864 Points2 Answers
-
Josh Keenan
20,315 Points4 Answers
-
John Koch
1,781 Points6 Answers
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