Regex Nothing to Repeat Error – Fix Leading Quantifiers

Local only

Diagnose a regex quantifier that appears where there is no preceding atom to repeat.

3 chars · 1 line

8 chars · 1 line

Pattern did not match the inputFlags: g

Regex quantifier error

How to fix a regex Nothing to repeat error

Quantifiers modify the token immediately before them. A pattern beginning with * has no preceding atom, so JavaScript rejects it before matching starts. 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. Locate the quantifier near the start of the syntax error.
  2. Identify the character, class, or group that the quantifier was meant to repeat.
  3. Move the quantifier after that atom, or escape it when the symbol should be literal.

Quantifiers cannot stand alone

The operators *, +, ?, and valid {n,m} forms are postfix operators in JavaScript regex syntax. They need an atom on their left before the pattern can compile.

Nothing to repeat regex example

Put the quantifier after the token it should repeat.

Invalid pattern

*abc

Corrected pattern

a*bc

Common questions

Frequently asked questions

Can * be matched literally?

Yes. Escape it as \* when the asterisk is data rather than a quantifier.

Does + have the same rule?

Yes. + and ? also require a preceding atom when used as quantifiers.

Why does the tester not inspect my input?

The regex does not compile, so JavaScript cannot begin matching the input text.

Debugging a specific Regex issue? Browse Regex troubleshooting.