JavaScript RegExp {X,} Quantifier

Beginner
⏱️ 9 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
At least n times

What You’ll Learn

The {X,} quantifier matches the previous token at least X times with no upper limit. Use \d{3,} for three-or-more digits, {8,} for minimum password length, and remember that + is shorthand for {1,}.

01

{n,}

At least n

02

{1,}

Same as +

03

{0,}

Same as *

04

vs {n}

Exact count

05

Greedy

Max match

06

{n,}?

Lazy mode

Introduction

Exact counts like {4} are perfect when length is fixed. But many rules only set a minimum: passwords must be at least eight characters, numbers need three or more digits, and repeated spaces should collapse to one. The {X,} quantifier handles that—at least X repetitions, as many as needed.

You already know + (one or more) and * (zero or more). Brace notation makes the minimum explicit: {1,} equals +, and {0,} equals *. Writing {3,} is clearer than guessing what “three or more” means in a complex pattern.

Understanding the {X,} At-Least Quantifier

Place {n,} after a token, where n is a non-negative integer. The engine matches that token at least n times in a row, then continues greedily if more matches are available.

JavaScript
/\d{3,}/.test("12");     // false — fewer than 3 digits

/\d{3,}/.test("123");    // true

/\d{3,}/.test("12345");  // true — more than 3 is allowed



"a{2,}".replace(/a{2,}/, "X");  // "X" from "aaa"

Unlike {n}, which stops at exactly n, {n,} has no maximum. The match grows until the token no longer applies or the rest of the pattern requires stopping (with backtracking if needed).

💡
Beginner Tip

In tutorials we write {X,} as a placeholder. In real patterns, replace X with a number: {3,}, {8,}. The trailing comma is required—{3} without a comma means exactly three, not three or more.

How to Use the {X,} Quantifier

Attach {n,} after a character class, metacharacter, dot, or grouped expression:

JavaScript
/\d{3,}/;              // three or more digits

/^.{8,}$/;             // at least 8 characters (whole field)

/\s{2,}/g;             // two or more whitespace chars

/(ha){2,}/;            // ha repeated at least twice

/\w{1,}/g;             // same idea as \w+

Use test() for yes/no checks, match() with g to find all qualifying runs, and ^…$ when the entire input must meet a minimum length.

📝 Syntax

JavaScript
token{n,}          // at least n repetitions, no max

{1,}               // one or more (same as +)

{0,}               // zero or more (same as *)

\d{3,}             // 3+ digits

.{8,}              // 8+ any chars

\s{2,}             // 2+ whitespace chars

Common patterns

  • /\d{3,}/ — find digit runs of three or more characters.
  • /^.{8,}$/ — password or field with minimum eight characters.
  • /\s{2,}/g — detect double (or more) spaces for cleanup.
  • /[A-Z]{2,}/ — two or more consecutive uppercase letters.
  • /(ab){2,}/ — at least two full ab group repetitions.

⚡ Quick Reference

GoalPattern / API
At least n digits\d{n,}
Minimum field length/^.{n,}$/
One or more (shorthand)+ or {1,}
Zero or more (shorthand)* or {0,}
Exactly n (not at least){n} — see {X} tutorial
Between n and m{n,m} — see next tutorial

📋 {n,} At-Least vs {n} Exact

Use {n,} when a minimum is enough; use {n} when length must be precise.

At least 2
a{2,}

Matches aa, aaa, aaaa…

Exactly 2
a{2}

Matches only aa

One or more
a+

Same as a{1,}

Zero or more
a*

Same as a{0,}

Examples Gallery

Open DevTools Console (F12) or use Try-it links. Examples cover minimum digit runs, exact vs at-least comparison, password length rules, whitespace cleanup, and grouped repetition.

📚 Getting Started

Require a minimum number of repetitions.

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,}/));

});

// 12     null

// 123    ["123"]

// 12345  ["12345"]

// ab12   null
Try It Yourself

How It Works

{3,} sets a floor of three digits but allows longer runs. "12345" matches the entire five-digit sequence greedily. Two-digit values like "12" fail the minimum.

📈 Practical Patterns

Compare quantifiers, validate length, and clean text.

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

See how adding a comma changes the rule from “exactly two” to “two or more.”

JavaScript
["a", "aa", "aaa"].forEach((s) => {

  console.log(s, /a{2}/.test(s), /a{2,}/.test(s));

});

// a   false false

// aa  true  true

// aaa true  true
Try It Yourself

How It Works

Both patterns match "aa" and find a valid run inside "aaa". The difference shows when you need an upper bound: {2} alone does not cap length—use {2,2} or anchors for strict two-character fields. {2,} explicitly documents “minimum two.”

Example 3 — Minimum Password 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

The dot matches any character; {8,} requires at least eight. Anchors ensure the whole string is measured, not a substring. Add character-class rules for letters, digits, or symbols separately.

Example 4 — Collapse Repeated Spaces with \s{2,}

Find two or more whitespace characters and replace them with a single space.

JavaScript
const messy = "Hello   world\t\ttest";



const cleaned = messy.replace(/\s{2,}/g, " ");

console.log(cleaned);  // "Hello world test"



console.log(messy.match(/\s{2,}/g));

// ["   ", "\t\t"]
Try It Yourself

How It Works

\s{2,} matches runs of spaces, tabs, or other whitespace that are at least two characters long. The global flag finds every run; replace normalizes them to one space.

Example 5 — Repeat a Group at Least Twice with (ha){2,}

Match laughter or rhythmic text where ha appears two or more times.

JavaScript
const words = ["ha", "haha", "hahaha", "hahahaha"];



words.forEach((w) => {

  console.log(w, /(ha){2,}/.test(w));

});

// ha        false — only one ha unit

// haha      true

// hahaha    true

// hahahaha  true
Try It Yourself

How It Works

Parentheses group ha as one token. {2,} requires at least two full repetitions, so single "ha" fails while "hahaha" succeeds with three units.

🚀 Common Use Cases

  • Minimum length validation — passwords, usernames, and comments with {n,} and anchors.
  • Number extraction — pull digit runs of at least a certain size from logs or CSV data.
  • Whitespace normalization — collapse double spaces, tabs, or mixed whitespace.
  • Repeated markers — detect two or more dashes, dots, or separator characters.
  • Explicit minimums — document intent when + is too vague (e.g. {3,} vs + after a group).
  • Text quality checks — flag words with [A-Z]{2,} (shouting) or long consonant runs.

Important Considerations

  • Trailing comma matters{3} is exact; {3,} is at least three. Do not omit the comma.
  • No upper bound{n,} allows unlimited length; use {n,m} when you need a maximum too.
  • Greedy default{n,} matches as many characters as possible; add ? for lazy matching.
  • Group precedenceab{2,} repeats only b; use (ab){2,} for the whole pair.
  • Substring matching — without anchors, {n,} finds qualifying runs anywhere in the string.
  • Not semantic validation — minimum length regex does not check password strength by itself.

🧠 How the {X,} Quantifier Works

1

Match minimum count

The engine repeats the preceding token until it reaches n consecutive matches.

Floor
2

Continue greedily

With no upper limit, it keeps matching the same token while characters still qualify.

Greedy
3

Stop at boundary

When the next character fails or the rest of the pattern needs a shorter run, matching stops or backtracks.

Bound
4

Proceed in pattern

After the quantifier succeeds, the engine continues with literals, anchors, or the next quantifier.

📝 Notes

  • + is shorthand for {1,}; * for {0,}.
  • Previous topic: {X} exact-count quantifier.
  • Next topic: {X,Y} bounded range quantifier.
  • See + for the one-or-more shorthand in depth.
  • Lazy form: {n,}? matches as few repetitions as possible.
  • Pair with ^ and $ for whole-field minimum length.

Browser & Runtime Support

The {n,} at-least quantifier is part of core JavaScript regular expression syntax.

Baseline · ES3+

RegExp {n,} quantifier

Supported in every browser and Node.js version. Use {n,} when a minimum repetition count is required.

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. {n,} is the explicit form of open-ended minimum repetition.

Conclusion

The {X,} quantifier matches the previous token at least X times with no upper limit. It powers minimum-length validation, long digit runs, whitespace cleanup, and any rule where “at least n” is enough. Remember that + and * are compact forms of {1,} and {0,}.

Watch the trailing comma, use groups when whole sequences repeat, and add anchors for full-field checks. When you also need a maximum, move on to {X,Y} bounded ranges.

💡 Best Practices

✅ Do

  • Use {n,} when the minimum count matters and length is unbounded
  • Write {3,} instead of + when clarity helps teammates
  • Combine ^.{n,}$ for minimum whole-field length
  • Wrap repeating sequences in (…){n,}
  • Try {n,}? when greedy matching consumes too much

❌ Don’t

  • Confuse {3} (exact) with {3,} (at least)
  • Use {n,} when you also need a maximum—use {n,m}
  • Forget anchors when validating entire input length
  • Write ab{2,} when you mean (ab){2,}
  • Rely on regex alone for password strength—check content rules too

Key Takeaways

Knowledge Unlocked

Five things to remember about the RegExp {X,} quantifier

Match minimum repetition counts with confidence.

5
Core concepts
📈 02

{1,}

Same as +.

Shorthand
📄 03

vs {n}

Exact count.

Compare
🔒 04

^.{8,}$

Min length.

Validate
🚫 05

Comma

Required.

Pitfall

❓ Frequently Asked Questions

The {X,} quantifier (use a number instead of X, such as {3,}) means at least X repetitions of the preceding token with no upper limit. Example: \d{3,} matches three digits, four digits, or any longer digit run.
{X} requires exactly X repetitions—no more, no fewer. {X,} requires at least X but allows more. So /a{2}/ matches only aa, while /a{2,}/ matches aa, aaa, aaaa, and so on.
Yes. The + quantifier is shorthand for {1,}—one or more repetitions. Both are greedy by default. Use whichever reads more clearly in your pattern.
Yes. The * quantifier means zero or more, which is equivalent to {0,}. Again, both are greedy unless you add ? for lazy matching.
Yes. Append ? after the quantifier for lazy (minimal) matching: /\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.
Did you know?

The comma in {n,} is what makes the quantifier open-ended. Without it, {3} means exactly three. With it, {3,} means three or more. That single punctuation mark is one of the most important details in brace quantifier syntax.

Continue to {X,Y} bounded range quantifier

Learn how {X,Y} sets both minimum and maximum repetition.

{X,Y} quantifier 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.

6 people found this page helpful