Quantifier
A regular-expression quantifier is syntax that specifies how many times a preceding pattern element may or must match.
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.
Also covered in
What to know first
- regular expressionA regular expression is a formal pattern notation that describes sets of strings and specifies how text can be matched, searched, or transformed.
- regex groupingA regex capturing group is a parenthesized regular-expression subpattern whose matched text is retained for separate access or reference.
- PythonPython is a high-level, general-purpose, dynamically typed programming language with readable syntax and support for multiple programming paradigms.
Related concepts
- regular expressionpart of · A regular expression is a formal pattern notation that describes sets of strings and specifies how text can be matched, searched, or transformed.
- greedy matchingincludes · Greedy matching is regular-expression behavior in which a quantifier matches as much text as possible while still allowing the overall pattern to match.
- non-greedy quantifierincludes · A non-greedy quantifier matches the fewest repetitions that allow the entire regular expression to match.
- regex termuses · A regex term is a component of a regular expression, such as a literal, character class, or group, that contributes to the pattern being matched.
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.



