--- title: Quantifiers slug: Web/JavaScript/Guide/Regular_expressions/Quantifiers page-type: guide sidebar: jssidebar --- Quantifiers indicate numbers of characters or expressions to match. {{InteractiveExample("JavaScript Demo: RegExp quantifiers", "taller")}} ```js interactive-example const ghostSpeak = "booh boooooooh"; const regexpSpooky = /bo{3,}h/; console.log(ghostSpeak.match(regexpSpooky)); // Expected output: Array ["boooooooh"] const modifiedQuote = "[He] ha[s] to go read this novel [Alice in Wonderland]."; const regexpModifications = /\[.*?\]/g; console.log(modifiedQuote.match(regexpModifications)); // Expected output: Array ["[He]", "[s]", "[Alice in Wonderland]"] const regexpTooGreedy = /\[.*\]/g; console.log(modifiedQuote.match(regexpTooGreedy)); // Expected output: Array ["[He] ha[s] to go read this novel [Alice in Wonderland]"] ``` ## Types > [!NOTE] > In the following, _item_ refers not only to singular characters, but also includes [character classes](/en-US/docs/Web/JavaScript/Guide/Regular_expressions/Character_classes) and [groups and backreferences](/en-US/docs/Web/JavaScript/Guide/Regular_expressions/Groups_and_backreferences).
| Characters | Meaning |
|---|---|
x*
|
Matches the preceding item "x" 0 or more times. For example,
|
x+
|
Matches the preceding item "x" 1 or more times. Equivalent to
|
x?
|
Matches the preceding item "x" 0 or 1 times. For example,
If used immediately after any of the quantifiers |
x{n}
|
Where "n" is a non-negative integer, matches exactly "n" occurrences of
the preceding item "x". For example, |
x{n,}
|
Where "n" is a non-negative integer, matches at least "n" occurrences of
the preceding item "x". For example, |
x{n,m}
|
Where "n" and "m" are non-negative integers and |
|
|
By default quantifiers like
Note: Adding |