Regexdrill

Free regex practice test

A ten-question regex quiz you answer by writing real patterns that run against test strings, one 15-minute clock, and a score broken down by skill area. No sign-up to start.

Questions
10
Minutes
15
Skill areas
5
Price
Free
/score: (\d+) of 10/Example result

Working knowledge

Correct
7 of 10
Time
10:43 of 15:00
Skill areaScoreShare correct
Basics2/2
Strong
Groups and alternation2/2
Strong
Real-world validation1/2
Review
Extraction and cleanup1/2
Review
Advanced1/2
Review
An example of the result you get: a score, your time, and each skill area marked.

What the test covers

Regular expressions come down to a short list of skills, from character classes to lookarounds. The test takes two questions from each of the five levels, picked at random each time.

  • Basics

    Literal text, character classes and ranges, counted repeats, anchors, escaping and the i flag. [a-z] \d + * ? ^ $

    2 of 1015 exercises
  • Groups and alternation

    Alternatives, capturing and non-capturing groups, optional and repeated groups, and backreferences. (...) (?:...) | \1

    2 of 1015 exercises
  • Real-world validation

    Whole-line patterns for the formats that come up at work: dates, times, email addresses, URLs, IP addresses and money. ranges built from alternation

    2 of 1020 exercises
  • Extraction and cleanup

    Pulling fields out of log lines, URLs and CSV rows, and search and replace: trimming, reformatting dates, stripping tags. captures $1 the g flag

    2 of 1018 exercises
  • Advanced

    Lookahead and lookbehind, lazy matching, named groups, and the m, s and u flags. (?=...) (?<!...) .*? (?<name>...)

    2 of 1020 exercises
No sign-up. No card.

Three sample questions

These come from the same pool as the test, one of each kind: match, extract and replace. In the test you type the pattern, the lines shown highlight as you type, and your answer is also checked on hidden test strings.

Q1US ZIP and ZIP+4

Real-world validation

The whole line must match. Match a five-digit ZIP code, optionally followed by a hyphen and four more digits.

Test lines9 lines shown, plus 4 hidden test strings in the exercise

LineShould match
90210yes
1234no
02134yes
123456no
12345-6789yes
12345-678no
00501yes
12345 6789no
ABCDEno
Show the answer

Pattern/\d{5}(?:-\d{4})?/

\d{5}(?:-\d{4})? allows 90210 and 12345-6789 but nothing in between.

Open this exercise

Q2Capture a standalone year

Groups and alternation

Capture the first standalone four-digit number on each line in group 1. Digits that are part of a longer number do not count. Lines without one give no match.

Lines to extract from4 lines shown, plus 3 hidden test strings in the exercise

LineExpected capture
Released in 1998"1998"
Copyright 2024 Acme"2024"
Founded 1887, rebuilt 1920"1887"
No year hereno match
Show the answer

Pattern/\b(\d{4})\b/

\b(\d{4})\b captures four digits with a boundary on each side, so 12345 is skipped instead of yielding 1234.

Open this exercise

Q3Reformat MM/DD/YYYY as YYYY-MM-DD

Extraction and cleanup

Rewrite every date written MM/DD/YYYY as YYYY-MM-DD. Leave everything else unchanged.

Lines to rewrite3 lines shown, plus 2 hidden test strings in the exercise

LineExpected output
Due 04/15/2025Due 2025-04-15
12/31/1999 and 01/01/20001999-12-31 and 2000-01-01
no dateno date
Show the answer

Pattern/(\d{2})/(\d{2})/(\d{4})/g

Replace with$3-$1-$2

(\d{2})/(\d{2})/(\d{4}) with the replacement $3-$1-$2 and the g flag reorders every date on the line.

Open this exercise

How scoring works

  • Each question is worth one point. You get the point when your pattern passes every line shown and every hidden test string, so a pattern that only fits the visible lines does not score.
  • You can check a pattern as often as you like while the clock runs. A question you skip, or have not solved when the 15 minutes end, counts as wrong.
  • The result shows your score out of 10, the time you took, and each skill area as strong or to review, with links to the exercises for the areas you missed.

What your score means

  • 0 to 4Build the basics first

    Start with the first levels and work up. Short daily practice moves this score quickly.

  • 5 to 7Working knowledge

    The core is there. The areas you missed are the ones to drill next.

  • 8 to 10Fluent on this set

    You solved questions from nearly every level under the clock. Drill the one or two areas you missed and you are in good shape.

These bands describe this test only. They are not a pass mark for any employer or course.

Take the test

10 questions from 5 skill areas, 15 minutes on the clock. It starts right here, with no account and no email.

  • Hints and answers are off while the clock runs.
  • Check a pattern as often as you like. Skip counts as wrong.
  • Your answers survive a page reload.

The mistakes that cost the most points

Six slips worth fixing before a timed regex test.

  • An unescaped dot. A dot matches any character, so 4.99 also matches 4x99. Write \. for a literal dot.
  • Greedy where lazy is needed. ".*" runs from the first quote to the last one on the line. ".*?" stops at the next quote.
  • Alternation that reaches too far. ^yes|no$ means starts with yes, or ends with no. Group the alternatives: ^(?:yes|no)$.
  • A match inside a longer value. \d{4} finds 1234 inside 12345. A word boundary on each side, \b\d{4}\b, keeps to standalone numbers.
  • A missing g flag in a replacement. Without g only the first match on the line is replaced.
  • Nested repeats. A pattern like (a+)+ can take a very long time on a near miss. The checker here rejects a pattern that runs too long.

The three kinds of question in the test

  • Match: write a pattern that matches the lines it should and none of the others. Some questions need the whole line to match, others count a match anywhere on the line.
  • Extract: capture the right part of each line in a group, such as the year in a sentence or the level in a log line.
  • Replace: write the pattern and the replacement text, such as turning MM/DD/YYYY into YYYY-MM-DD.

Questions

Is the regex practice test really free?

Yes. The test and every exercise on Regexdrill are free. There is no card, no daily limit and nothing to unlock.

Do I need an account or any software?

No to both. The test starts in one click and runs in your browser. The lines shown highlight as you type, and your answer is checked on the server against hidden test strings.

How long does the test take?

Up to 15 minutes. There are 10 questions on one clock, and the test ends when you finish the last question or the time runs out.

How is the test scored?

One point per question, 10 in total. A pattern scores when it passes every line shown and every hidden test string. Skipped or unsolved questions count as wrong. You also get a breakdown by skill area.

Is this a multiple-choice regex quiz?

No. Every question is hands-on: you type a pattern, and for replace questions the replacement text, and it is run against real test strings. That is closer to how regular expressions are used at work than picking an answer from a list.

Which regex flavor does the test use?

The JavaScript flavor, with the flags g, i, m, s and u. Character classes, groups, backreferences, lookahead, lookbehind and named groups work as they do in current browsers. Most of what you practice carries over to Python, Java and PCRE with small differences.

Can I retake the test?

Yes, as often as you like. The questions are drawn at random from the exercise pool, so a retake is a different test.

What comes after the test?

Your result links straight to the exercises for the areas you missed. All 88 exercises are free, each with hidden test strings and a reference answer. Certificates come with the Dravari bundle.

Find out where you stand

Ten questions, 15 minutes, a score by skill area. Free, and no sign-up to start.