How to Learn Regex as a Beginner: A Simple Plan
Updated November 2026
Written by the Toolpuffin team. Tools in this guide are tested in the browser.
Regular expressions, or regex, look like a wall of symbols at first. They are easier than they look if you learn the symbols one at a time and test each one on real text. This guide gives a simple order to learn them in and a free course to practise with.
What a regular expression is
A regular expression is a pattern that describes text. You use it to find, check or replace text: for example to check that a postcode has four digits and two letters, or to find every number in a long text. Many programming languages, text editors and search tools understand regex, and the basic symbols are almost the same everywhere.
What to learn first
- Plain text: a pattern of letters finds those letters.
- The dot . for any one character.
- \d for a digit, \w for a letter or digit and \s for a space.
- Repeating with +, * and ? and with numbers in curly brackets such as {4}.
- ^ and $ for the start and the end of the text.
- Choices with | and groups with round brackets.
- Sets of characters in square brackets, such as [A-Z].
Learn them in this order. Each step builds on the one before, and after the last one you can already write a pattern for a Dutch postcode.
How to practise
Reading about regex helps less than trying it. The free course has 8 short lessons: you type a pattern and a list of example texts shows at once which ones it finds and which it does not.
When you want to try a pattern on your own text, use the regex tester. It highlights the matches as you type.
Common mistakes
- Forgetting ^ and $. Without them a pattern also finds a match inside a longer text, so 20a still contains digits.
- Forgetting to escape a dot. A plain . means any character, so to find a real dot write \.
- Only testing texts that should match. Also test texts that should not match, because that is where a pattern that is too loose shows up.
- Using regex for everything. A simple pattern can check the shape of an email address, but it cannot prove the address exists.
What to learn next
After the basics, learn the flags: i to ignore capitals, g to find all matches and m to work on each line. Then look at groups that remember what they matched, and at cheat sheets and ready-made examples to copy and change.