Skip to content

↑↓ moveEnter openEsc close

Regex practice

Regex ECMAScript 2025 · 46 patterns · checked Nov 2026 · Source: MDN regex reference

Read what to match, then write the pattern. Any regex that passes the checks counts, not just the one in the answer.

46 patterns in 8 lessons. Your progress is kept in this browser.

Lessons

  1. 1Characters and classes9 patterns

    .\d\D\w\s[aeiou][^aeiou][a-z][0-9a-fA-F]

  2. 2Quantifiers7 patterns

    a*\d+colou?r\d{3}[a-z]{2,4}.{8,}<.*?>

  3. 3Anchors and boundaries5 patterns

    ^Hello\.js$^\d+$\bcat\b\Bcat\B

  4. 4Groups and alternation5 patterns

    cat|dog(ha)+(?:https://)?example\.com(?<year>\d{4})\b(\w+) \1\b

  5. 5Lookarounds4 patterns

    \d+(?=px)foo(?!bar)(?<=\$)\d+(?<![-\d])\d+

  6. 6Flags4 patterns

    /hello/i/cat/g/^#/m/a.*b/s

  7. 7Escaping4 patterns

    \.\(1\+1\)\\\r?\n

  8. 8Common patterns8 patterns

    -?\d+\d+(\.\d+)?#[0-9a-fA-F]{6}\d{4}-\d{2}-\d{2}\S+@\S+\.\S+^\s+|\s+$/^\s*$/m\b(red|green|blue)\b

How practice works

Each question describes what to match, and you write the pattern. Your answer is run against example strings, so any regex that matches the right text and nothing else is accepted. Write flags as /pattern/flags.

  • Learn shows each new pattern with its answer to type once, then asks for it again without help, and schedules the next review.
  • Practice goes through a lesson at your own pace. Press Esc to see the answer. It does not change your reviews.
  • Speed run asks every item once, without answers, against the clock. Get 70% right first time to pass.
  • Today's session brings back what is due for review plus a few new ones.

A wrong answer tells you what was off, such as the text a pattern missed. After two tries the answer is shown, and you type it to move on. Progress is stored in this browser only; the daily goal and streak are shared with the keyboard shortcut practice.

To look something up instead, use the regex syntax list.