liveBook · Manning

Quantifier

A regular-expression quantifier is syntax that specifies how many times a preceding pattern element may or must match.

How 4 Manning books explain it

The Well-Grounded Rubyist, Fourth Edition

A regular-expression quantifier is a syntax element that specifies how many consecutive times a preceding pattern element may match.

How it is used
Constrains consecutive repetitions in Ruby regular expressions, complementing anchors that constrain match position and modifiers that change matching behavior.
How deep it goes
Works through shorthand and counted repetition, greediness, backtracking, and capture placement with match results.
Examples
Uses optional titles, flexible whitespace in a closing tag, digit runs, exclamation-delimited strings, and uppercase-group captures.
What you can do after
Apply it via Ruby regular expressions to specify optional, repeated, or bounded patterns and distinguish greedy from non-greedy matches.

Read how The Well-Grounded Rubyist, Fourth Edition explains quantifier →

Secrets of the JavaScript Ninja, Third Edition

A repetition operator is a regular-expression quantifier that specifies how many times a preceding pattern may occur.

How it is used
Specifies allowed repetition in JavaScript regular expressions, from optional runs to fixed or ranged counts.
How deep it goes
Defines the main counts, demonstrates greedy and nongreedy matching, and traces how repeated groups can trigger backtracking.
Examples
Uses anchored word patterns, angle-bracketed text, and a timed JavaScript roster check with a failing input.
What you can do after
Diagnose/debug with it when greedy matching captures too much or repeated groups make a failing match slow.

Read how Secrets of the JavaScript Ninja, Third Edition explains quantifier →

Secrets of the JavaScript Ninja, Second Edition

A regular-expression operator that specifies how many times a preceding term may occur.

How it is used
Uses quantifiers to specify repetition of a preceding regular-expression term.
How deep it goes
Defines quantifiers by their repetition role but provides no visible syntax or mechanics.
What you can do after
Understand how a quantifier specifies repetition of a term in a regular expression.

Read how Secrets of the JavaScript Ninja, Second Edition explains quantifier →

Python How-To

A quantifier is a regular-expression construct that specifies how many occurrences of a preceding element may or must appear.

How it is used
Uses quantifiers to build regular-expression searches and extract values from text containing variable-length elements or separators.
How deep it goes
Defines six quantifier forms, demonstrates greedy and non-greedy matching, and stops short of regular-expression engine internals.
Examples
Demonstrates h and i repetitions, Python re.findall output, and extraction from values separated by one or more separators.
What you can do after
Apply it via Python regular expressions to match bounded, unbounded, greedy, or shortest variable-length sequences.

Read how Python How-To explains quantifier →

Also covered in

What to know first

Related concepts

Questions about quantifier

What is quantifier?

A regular-expression quantifier is syntax that specifies how many times a preceding pattern element may or must match.

Which Manning books explain quantifier?

The Well-Grounded Rubyist, Fourth Edition, Secrets of the JavaScript Ninja, Third Edition, Secrets of the JavaScript Ninja, Second Edition and Python How-To.

What should I know before learning quantifier?

Manning books that teach quantifier usually introduce regular expression, regex grouping and Python first.

What kinds of quantifier are there?

Kinds of quantifier include greedy matching, non-greedy quantifier, bounded quantifier and zero-or-more quantifier.

What is quantifier part of?

Quantifier is part of regular expression. A regular expression is a formal pattern notation that describes sets of strings and specifies how text can be matched, searched, or transformed.

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.