Module 18
Regular Expressions
Learn pattern matching and text processing using Python's re module.
01
Regular Expressions — Search Patterns with the re Module
Learn what a Python regular expression is, why the re module exists, and the path from search functions to classes and quantifiers.
02
re Functions — findall, search, finditer, and sub
Search Python text with findall, search, and finditer, then read group(), start(), and end(), or replace the match with sub.
03
Character Classes — Brackets, Ranges, and a Caret
Write Python regex character classes with brackets, ranges, and a leading caret to keep letters, digits, or everything else.
04
Predefined Classes — Digits, Word Characters, and Spaces
Use Python's predefined regex classes for digits, non-digits, word characters, symbols, spaces, and non-spaces in a string.
05
Quantifiers — How Many Characters a Pattern Needs
Count each Python regex match with +, *, ?, and braces such as {m} and {m,n} for an exact count or a minimum and maximum.
06
Validation Patterns — Codes, Words, and Decimals
Combine Python regex classes and quantifiers to check a 10-digit code, a 3-letter word, and a number with two decimal places.