A small course in 8 short lessons on regular expressions. Each lesson explains one idea and gives you a task. You type a pattern and see at once which example texts it finds and which it does not. You end with a pattern for a Dutch postcode.
0 of 8 lessons done. Your progress is saved in this browser.
1. Plain text
A regular expression (regex) describes a pattern in text. The simplest pattern is just letters: it finds those letters in the text. The pattern cat finds cat anywhere, also inside category.
Your task: Type a pattern that finds the texts that contain cat, and not the others.
catshould be found✗black catshould be found✗categoryshould be found✗dogshould not be found✓cashould not be found✓c a tshould not be found✓
The pattern is tested in your browser, without flags, so capitals and small letters count as different.
Features
- 8 short lessons, from plain text to a postcode pattern
- A list of example texts that shows right away what your pattern finds
- A hint and the full answer for every lesson
- Your progress is remembered in this browser
How to use Learn Regex
- Read the lesson and the task.
- Type a pattern and check the list of example texts.
- Use the hint or the answer if you are stuck.
- Go to the next lesson.
Frequently asked questions
Do I need to know how to code?
No. The lessons start with plain text and build up step by step.
Where can I use what I learn?
Regular expressions work in many programming languages and in text editors and search tools. The symbols you learn here are almost the same everywhere.
Why are capitals and small letters different?
The exercises are tested without flags. With the i flag the difference is ignored. You can try that flag in the regex tester.
Is my pattern saved?
Only which lessons you finished is saved, in this browser. What you type is not stored or sent anywhere.