Re
The re module is Python’s standard-library module for compiling and applying regular expressions to text.
Tiny Python Projects: Learn coding and testing with puzzles and games
re is Python's standard-library module for matching and manipulating text with regular expressions.
- How it is used
- Uses regular-expression patterns to match, substitute, and split text when direct string methods become cumbersome.
- How deep it goes
- Introduces character classes, repetition, matching position, substitution, and splitting, but deliberately scratches only the surface of regexes.
- Examples
- Demonstrates vowel replacement, initial-consonant matching, and comma-based splitting.
- What you can do after
- Apply it via Python’s re module to replace matched text, detect patterns at chosen positions, and split text with regex delimiters.
Read how Tiny Python Projects: Learn coding and testing with puzzles and games explains re →
The Quick Python Book, Fourth Edition
re is Python's standard-library module for matching and processing text with regular expressions.
- How it is used
- Handles flexible text searching, pattern extraction, replacement, splitting, and recognition beyond literal substring operations.
- How deep it goes
- Explains patterns, compilation, search results, raw strings, replacements, flags, and match processing without detailing every special character.
- Examples
- Uses whitespace normalization and line counting for text containing the word hello.
- What you can do after
- Apply re.compile, search, and sub to detect patterns, inspect matches, count matching lines, and normalize text.
Read how The Quick Python Book, Fourth Edition explains re →
Related concepts
- regular expressionuses · A formal pattern notation that describes sets of strings and enables text to be matched, searched, extracted, or transformed.
- standard librarypart of · A standard library is a collection of reusable modules, types, functions, APIs, and other facilities distributed with a programming language implementation or platform.
- Pythonused by · Python is a high-level, general-purpose, dynamically typed programming language known for readable syntax and automatic memory management.
- ChatGPTused by · ChatGPT is OpenAI’s conversational AI service, which lets users interact with generative AI models and related tools through natural-language prompts.
- re.compilehas part · re.compile is a Python standard-library function that compiles a regular-expression pattern into a reusable pattern object.
- splithas part · Split is an operation or function that divides a string or sequence into parts according to a separator, pattern, or other rule.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

