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, 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.
Related concepts
- regular expressionused by · A formal pattern notation that describes sets of strings and enables text to be matched, searched, extracted, 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 groupingused by · A regex capturing group is a parenthesized regular-expression subpattern whose matched text is retained for separate access or reference.
- regular expression atomconfigures · A regular expression atom is a single repeatable unit of a regular-expression pattern, such as a character, character class, or parenthesized subpattern.
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.


