Using re.match, re.search, re.findall
Apply core re functions to find patterns in strings.
Using re.match, re.search, re.findall is a free Python Academy lesson on CoddyKit — lesson 2 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Python Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Introduction
re.match() — Start of String
import re
print(re.match(r'\d+', '123abc')) # match
print(re.match(r'\d+', 'abc123')) # Nonere.search() — Anywhere
import re
m = re.search(r'\d+', 'abc 123 def')
if m: print(m.group())re.findall() — All Matches
import re
print(re.findall(r'\d+', 'one 1 two 22 three 333'))re.finditer() — Iterator
import re
for m in re.finditer(r'\d+', 'x1 y22 z333'):
print(m.group(), m.start(), m.end())Match Object Methods
import re
m = re.search(r'(\w+)@(\w+)', 'send to user@example')
if m:
print(m.group(), m.group(1), m.group(2))re.fullmatch()
import re
print(re.fullmatch(r'\d+', '123')) # match
print(re.fullmatch(r'\d+', '123abc')) # Nonere.split()
import re
print(re.split(r'[,;\s]+', 'one,two; three four'))re.sub() for Replacement
import re
print(re.sub(r'\d+', 'NUM', 'I have 3 cats and 12 dogs'))Compiled Patterns
import re
digits = re.compile(r'\d+')
print(digits.findall('abc 123 def 456'))Flags
import re
print(re.findall(r'hello', 'HELLO World', re.IGNORECASE))Quick Check
Recap
Keep Going
Frequently asked questions
Is the “Using re.match, re.search, re.findall” lesson free?
Yes — the full text of “Using re.match, re.search, re.findall” is free to read here on the web, and the Python Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Python Academy course, upgrade to CoddyKit PRO.
What will I learn in “Using re.match, re.search, re.findall”?
Apply core re functions to find patterns in strings. You practise Python Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Python Academy?
No prior experience is required. Python Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 2 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Using re.match, re.search, re.findall” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Python Academy lesson?
Yes. Every Python Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Regex Fundamentals
- Using re.match, re.search, re.findall
- Groups and Named Captures
- re.sub, Flags, and Compiled Patterns