Skip to main content
Module 2 · Lesson 1 of 45/32 in the course~16 min
Module lessons (1/4)

`*`, `+`, `?`

Lesson preview5 hands-on exercises readyRegex Course · Module 2 — Quantifiers

Zero or more, one or more, optional: the three basic quantifiers.

What you'll learn in this lesson

  • Master the three fundamental multiplicity quantifiers: * (0 or more), + (1 or more), and ? (0 or 1, optional).
  • Distinguish between empty matches generated by * on inputs lacking the searched character and minimum guarantees of +.
  • Understand that each quantifier acts only on the atom immediately preceding it (and use (...) for optional whole words).
  • Combine default classes (\d+, \s+) and optionalities (-?, colou?r) into realistic patterns.

Overview

Quantifiers tell the engine how many times to repeat the element before them. The three basic building blocks are *, +, and ?: each applies strictly to the single atom immediately to its left (a character, a class like \d, or a group (ab)).

Sections covered in this lesson

  1. 1Mental model: *, + and ? compared
  2. 2Progressive examples
  3. 3Guided laboratory
  4. 4Check for understanding
Pro Lesson · Module 2 — Quantifiers

Unlock "`*`, `+`, `?`" and the full Regex Course curriculum

Zero or more, one or more, optional: the three basic quantifiers.

Unlock all 5 hands-on exercises in this lesson plus every advanced WebAssembly module with automated checks.

  • Instant access to all advanced modules in Regex Course plus 17 more courses
  • Hands-on browser exercises with automated test suites and solutions
  • 14-day money-back guarantee processed via Paddle.com

14-day guarantee · Cancel anytimeModule 1, all 18 interactive games, and cheatsheets are always free.