"Invalid regular expression": nothing to repeat, unterminated group, bad range

Last reviewed 2026-09-19

A regular expression engine stops at the first thing it cannot understand: a parenthesis or bracket that is not closed, a quantifier like * with nothing before it, a backwards character range or a stray backslash.

Messages you might see

  • “Invalid regular expression: /(/: Unterminated group”
  • “Nothing to repeat”
  • “Range out of order in character class”

Why it happens

  • Unbalanced parentheses or square brackets.
  • A quantifier (*, +, ?) with nothing to repeat, often after ( or at the start.
  • A character range written backwards, such as z-a.
  • A backslash that escapes the wrong thing, or an unsupported flag.

Try this first (free, no tool needed)

  1. Paste the pattern into a regex tester that highlights groups and shows which part is invalid.
  2. Count opening and closing brackets and read the pattern piece by piece.
  3. Remember flavours differ: a pattern valid in PCRE may be invalid in JavaScript.

If that didn't work

These tools run in your browser. Your file is read and repaired on your own device and is never uploaded.

Broken Regex Pattern Fixer

Repairs unbalanced parentheses and brackets, quantifiers with nothing to repeat, stray backslashes, backwards character ranges and invalid flags, one pattern per line, and adds a comment explaining each change. Valid patterns are never modified. It repairs syntax; whether the result matches what you meant is for you to test.

Open Broken Regex Pattern Fixer

Common questions

Does it know what I wanted to match?

No. It fixes syntax so the pattern compiles. Always test the repaired pattern on sample text.

Is my file uploaded anywhere?

No. The tool runs as a program inside your own browser, so the file is read and repaired on your device and never sent to a server.

Related guides