Track 7 · Lesson 9 of 11
Regex groups, findall and substitution
Extract parts of a match with numbered and named groups, find every match with findall and finditer, rewrite text with re.sub, and adjust matching with flags.
You will be able to
- Capture parts of a match with numbered groups and named groups, and read them with group(), groups() and groupdict()
- Collect every match with re.findall() and re.finditer(), and predict what findall returns when the pattern has groups
- Rewrite text with re.sub() using backreferences and replacement functions
- Change how patterns match with re.IGNORECASE, re.MULTILINE, re.VERBOSE and re.ASCII, and reuse patterns with re.compile()
Included with a Formula Quest membership
It has 5 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.