Regex Invalid Quantifier Range – Fix {min,max} Order

Local only

Repair a JavaScript regex repetition range whose minimum count is greater than its maximum.

3 chars · 1 line

8 chars · 1 line

Pattern did not match the inputFlags: g

Regex repetition error

How to fix an invalid regex quantifier range

A bounded quantifier uses {min,max}. JavaScript rejects a range when min is greater than max, such as a{3,2}. This tool is free to use. No account or payment is required.

Last updated

What you can do here

  • JavaScript RegExp validation
  • Broken pattern preloaded
  • Corrected pattern comparison
  • Configurable regex flags
  • Browser-native error feedback
  • Browser-local processing

Steps

  1. Find the {min,max} quantifier named by the failing pattern.
  2. Compare its lower and upper bounds.
  3. Reduce the minimum or increase the maximum so min is not greater than max.

The lower repetition bound cannot exceed the upper bound

{2,3} means at least two and at most three repetitions. Reversing those bounds describes an impossible interval, so JavaScript rejects the pattern.

Invalid regex quantifier range example

Put the smaller count first.

Invalid pattern

a{3,2}

Corrected pattern

a{2,3}

Common questions

Frequently asked questions

Is {3,} valid?

Yes. It means at least three repetitions with no explicit upper bound.

Is {3} valid?

Yes. It means exactly three repetitions.

Can braces be literal?

Yes, depending on context and escaping, but braces that form quantifier syntax must describe valid bounds.

Debugging a specific Regex issue? Browse Regex troubleshooting.