JavaScript RegExp {n,} Quantifier

Beginner
7 min read
Updated: Oct 2026
3 examples
Live preview

What Is the {n,} Quantifier?

Place {n,} after a token to match it at least n times, with no upper limit. The trailing comma is what means “or more.” Greedy by default — it takes as many as it can.

Remember
token{n,}    → n or more of token
\d{3,}       → "123" ✓ · "12345" ✓ · "12" ✗
.{8,}        → at least 8 characters

{2} exact    ·  {2,} two or more  ·  {2,4} between 2 and 4
{1,} = +     ·  {0,} = *
UsePrefer
At least ntoken{n,}
Exactly ntoken{n}
Between n and mtoken{n,m}

How to Use {n,}

Attach {n,} when you need a minimum count but no maximum.

  1. Choose the token to repeat — e.g. \d, ., \s, (ha).
  2. Add {n,} with your minimum — e.g. \d{3,}, .{8,}.
  3. Remember it is greedy: longer runs are preferred when they still let the rest succeed.
  4. Use ^ and $ when validating a whole field’s minimum length.
PieceRequired?Role
Preceding tokenYesWhat repeats
{n,}YesMinimum count; no upper bound
? after itOptionalLazy form: {n,}?

Pseudocode

Pseudocode
pattern = <token>{n,}

// greedy: take as many as possible, then backtrack if needed
count = 0
while next input matches <token>:
    count = count + 1

if count < n:
    fail
else:
    // success — count is at least n
    continue with rest of pattern

Cheat Sheet

Keep these facts handy while writing minimum-count patterns.

TopicDetail
MeaningAt least n of the previous token
Digits\d{3,} — three or more digits
Min length/^.{8,}$/
Whitespace runs\s{2,}
Shorthand{1,} = + · {0,} = *
Lazy{n,}? — as few as possible (≥ n)
StandardES3+ (universal)

Live Preview

Pick an “n or more” pattern and a sample string to see test() / match() results.

Browser demo of the {n,} quantifier — same idea as the examples below.

Result
pattern = /\d{3,}/
text    = "12"
test()  → false
match() → null

/* need at least three digits */

JavaScript Examples

Short, copy-ready snippets. Open DevTools Console, or use Try It Yourself for a live editor.

Example 1 — Match Three or More Digits with \d{3,}

Find digit runs where at least three digits appear in a row.

JavaScript
const samples = ["12", "123", "12345", "ab12"];

samples.forEach((s) => {
  console.log(s, s.match(/\d{3,}/));
});
Try It Yourself

How It Works

  1. Set a floor. {3,} needs at least three digits.
  2. Short fails. "12" and "ab12" never reach three → null.
  3. Exact minimum works. "123" matches the whole run.
  4. Greedy keeps more. "12345" matches all five digits, not just three.

Example 2 — {2} Exact vs {2,} At-Least

See how the trailing comma changes how much of a longer run is kept.

JavaScript
const s = "aaa";

console.log(s.match(/a{2}/));   // ["aa"]  — exactly two
console.log(s.match(/a{2,}/));  // ["aaa"] — two or more (greedy)

console.log(/a{2}/.test("a"));   // false
console.log(/a{2,}/.test("a"));  // false — both need ≥ 2
Try It Yourself

How It Works

  1. Exact stops at two. /a{2}/ on "aaa" returns "aa".
  2. At-least keeps going. /a{2,}/ greedily takes all three a characters.
  3. Same floor. Both reject a single "a" — the minimum is still two.
  4. Rule of thumb. Need a fixed width? Use {n}. Need a minimum? Use {n,}.

Example 3 — Minimum Length with ^.{8,}$

Require at least eight characters for the entire input.

JavaScript
const rule = /^.{8,}$/;

console.log(rule.test("short"));       // false
console.log(rule.test("longenough"));  // true
console.log(rule.test("verylongpass")); // true
Try It Yourself

How It Works

  1. Any character. . matches one char; {8,} needs eight or more.
  2. Whole string. ^ and $ measure the full value, not a substring.
  3. Short fails. "short" has five characters → false.
  4. Longer is fine. There is no upper bound — eight, nine, or twenty all pass.

Edge Cases & Pitfalls

Check these before relying on {n,} in real projects.

greedy

Takes as many as possible

\d{3,} on "12345" returns all five digits. Use {n,}? for the shortest run that still meets the minimum.

comma

Do not omit the trailing comma

{3} is exact. {3,} is three or more. The comma is the whole difference.

anchors

Minimum length needs ^…$

Without anchors, .{8,} can match eight characters inside a longer string. Use /^.{8,}$/ for whole-field checks.

choice

Need an upper bound?

Switch to {n,m}. For “one or more,” + is the same as {1,}.

Browser & Runtime Support

The {n,} quantifier is part of core JavaScript regex (ES3+). It works everywhere without polyfills.

✓ Baseline · ES3+

RegExp {n,} quantifier

Supported in every modern and legacy browser, plus all Node.js versions. Universal syntax for n-or-more repetition.

99% Universal syntax
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Bun Supported · JavaScript runtime
Supported
Deno Supported · JavaScript runtime
Supported
Node.js Supported · Server runtime
Supported
Android WebView Supported · Modern WebView
Full support
{n,} Excellent

Bottom line: Safe everywhere. Use {n,} whenever you need a minimum count with no upper limit.

Performance Notes

Pattern styleCostBest for
\d{n,} / \w{n,}Usually cheapMinimum runs of known classes
^.{n,}$CheapWhole-string minimum length
Open .* + nested bracesCan explodePrefer specific classes and clear bounds

Simple {n,} patterns are fine in everyday code. Prefer specific classes (\d, \s) over open . when you can, and add an upper bound with {n,m} if unbounded matching is risky.

Key Takeaways

  • Role: {n,} means at least n — no maximum.
  • vs {n}: the comma is what unlocks “or more.”
  • Shorthand: {1,} = +, {0,} = *.
  • Greedy: longer runs win unless you use {n,}?.

One line: {n,} sets a floor with no ceiling — perfect for minimum length and “at least this many” runs.

Frequently Asked Questions

The {n,} quantifier means at least n repetitions of the preceding token, with no upper limit. Example: \d{3,} matches three digits, four digits, or any longer digit run.
{n} requires exactly n repetitions. {n,} requires at least n and allows more. So /a{2}/ matches a run of exactly two a's, while /a{2,}/ greedily takes two or more.
Yes. + is shorthand for {1,}—one or more repetitions. Both are greedy by default. Use whichever reads more clearly in your pattern.
Yes. * means zero or more, which is equivalent to {0,}. Both are greedy unless you add ? for lazy matching.
Yes. Append ? after the quantifier: /\d{3,}?/ matches as few digits as possible while still meeting the minimum of three.
Brace quantifiers including {n,} are core JavaScript regex syntax since ES3. They work in every browser and Node.js version without polyfills.

Next: {n,m} range quantifier

Learn how to require between n and m repetitions inclusive.

{n,m} tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

7 people found this page helpful