Regex Tutorial
Regex Tutorial
Learn regular expressions step by step with hands-on matching exercises.
Regular expressions are the fastest way to find, validate, or extract patterns in text — email addresses, log lines, phone numbers, you name it — but the syntax (anchors, quantifiers, character classes, groups) is easy to half-remember and misuse.
This tutorial builds up from literal characters to full patterns with groups and alternation. Each step gives you sample text and an expected match; you write the pattern and we check it against a real regex engine.
What you'll practice (11 steps)
- Literal characters
- The dot: any character
- Character classes
- Ranges and negation
- Quantifiers: how many
- Shorthand classes: \d \w \s
- Explicit counts: {n,m}
- Anchors: ^ $ and \b
- Alternation: this or that
- Capturing groups
- Named capturing groups