Track 7 · Lesson 8 of 11
Regular expressions: the basics
Describe text patterns with regular expressions and test them with re.search, re.match and re.fullmatch, using character classes, quantifiers and anchors.
You will be able to
- Explain what a regular expression is and why patterns are written as raw strings
- Choose between re.search(), re.match() and re.fullmatch(), and read a match object
- Use character classes (\d, \w, \s, [A-Z], [^...]) and quantifiers (*, +, ?, {n,m})
- Anchor patterns with ^, $ and \b, and escape special characters
- Replace a hand-written validator with a single fullmatch pattern
Included with a Formula Quest membership
It has 4 graded exercises with feedback, hints and solutions. Python Quest is included in Formula Quest memberships that cover Python; membership and billing are managed on Formula Quest.
View Formula Quest memberships
Tracks 1 and 2, the first lesson of every track, the playground and the dataset library are free.