Regular Expressions for Beginners / Chapter 1 — First Steps with Regular Expressions (lessons 1–5) / Lesson 1

What a Regular Expression Is: Searching by Shape, Not by Text

Time needed: about 12 min (estimate)

☆ Read later

You can try the opening of this lesson without an account.

What you want is a shape, not fixed text

The subject of this course is the orders and logs of a small bakery, Komugi-do. Each order gets a number like KM-20261103-0042: KM-, eight digits for the date, -, and a four-digit serial for that day. When you want to pull every order number out of the intake notes, plain search gets stuck. Every number is different, so there is no single text to search for.

editor.py

Tab indents. To leave the editor, press Esc, then Tab.

Create a free account to keep reading

With an account you can read the rest of this lesson, take the quiz, and read every free lesson in this course. Lessons you answer correctly are recorded as complete.

Report a problem with this lesson

Log in to send a report.

Keyboard shortcuts

Keys available in a lesson
KeyAction
[ or Alt + ←Go to the previous lesson
] or Alt + →Go to the next lesson
?Open this list
EscClose this list

The keys do not work while the cursor is in a code editor or an input field.