Regex Quiz
Test your pattern matching knowledge. — 6 questions
About the Regex Quiz
Test your pattern matching knowledge. This quiz has 6 multiple-choice questions. Each question has one correct answer, and you see an explanation straight after you answer, so you learn from every question — including the ones you get wrong. There is no time limit and nothing to sign up for; your answers are not stored.
The questions follow the material in the Regex Crash Course guide and the Regular Expressions cheatsheet. Read them first if you want to prepare, or take the quiz cold to find the gaps in what you know.
Questions in this quiz
Preview the questions below. Each answer and its explanation are hidden until you choose to reveal them, so you can still take the quiz above without spoilers.
1. What does \d match?
Show answer
Answer: B. Any digit 0–9
\d is shorthand for [0-9] — it matches any single digit.
2. What does ^ mean at the start of a pattern?
Show answer
Answer: B. Start of string
^ anchors the match to the start of the string. Inside a character class [^abc] it means NOT.
3. What does [^abc] match?
Show answer
Answer: B. Everything except a, b, c
^ inside a character class negates it. [^abc] matches any character that is not a, b, or c.
4. What does the + quantifier mean?
Show answer
Answer: B. 1 or more
The + quantifier requires at least one match. Use * for zero or more.
5. Which character matches the end of a string?
Show answer
Answer: C. $
$ anchors the match to the end of the string (or line, with multiline flag).
6. What does {2,5} mean after a pattern?
Show answer
Answer: B. Between 2 and 5 occurrences
{2,5} is a range quantifier — it matches between 2 and 5 occurrences of the preceding pattern.
How to use this quiz
- Answer every question before reading the explanations below — retrieving an answer from memory is what makes it stick.
- Note the questions you missed and revisit the matching section of the guide or cheatsheet.
- Retake the quiz a day or two later. Spaced repetition is one of the most reliable ways to remember technical details.