Skip to content
derpx06.dev
WritingExplainersNotesAbout
works on my machineit's always DNSship itLGTMTODO: sleepoff by oneread the docsgit push --force-with-lease404: sleep not foundhave you tried turning it off and on againrubber duck says: explain itpremature optimisationworks on my machineit's always DNSship itLGTMTODO: sleepoff by oneread the docsgit push --force-with-lease404: sleep not foundhave you tried turning it off and on againrubber duck says: explain itpremature optimisation

Learning in public.

A student's notebook on system design, distributed systems and databases. Shared as I learn.

ReadWritingExplainersNotesAbout
ElsewhereGitHubLinkedInHugging FaceLeetCode
Say hellomanaskhairnar1511@gmail.com
derpx06
NORMALmain© 2026 Derpx06Pune, Indiatop ↑
Learn/Python Overview/Part 5 · 5. Data Work
Lesson 14 of 17

Regular Expressions

Searching text with pattern matching.

Derpx061 Jan · 1 min read
Python Overview
RandomnessRegular ExpressionsObject-Oriented ProgrammingIterators & ZipArgs & Kwargs
0% read · 1 min leftBack to top ↑
Course outline & contents0%
Python Overview
RandomnessRegular ExpressionsObject-Oriented ProgrammingIterators & ZipArgs & Kwargs

Regular expressions provide a way of searching text. They are incredibly useful but also fairly complicated, so much so that there are entire books written about them.

We will explain their details the few times we encounter them; here are a few examples of how to use them in Python:

regex.py
import re

print all([                                 # all of these are true, because
  not re.match("a", "cat"),               # * 'cat' doesn't start with 'a'
  re.search("a", "cat"),                  # * 'cat' has an 'a' in it
  not re.search("c", "dog"),              # * 'dog' doesn't have a 'c' in it
  3 == len(re.split("[ab]", "carbs")),    # * split on a or b to ['c','r','s']
  "R-D-" == re.sub("[0-9]", "-", "R2D2")  # * replace digits with dashes
]) # prints True
Track your progressSign in and your progress follows you across devices.
Sign in to track progress Next lesson
← Previous lessonRandomnessNext lesson →Object-Oriented Programming