W

Regex Invalid Capture Group

Regular expression engines throw group errors when parentheses are unbalanced, named groups use invalid syntax, or lookbehind/lookahead assertions are malformed. JavaScript limits some features (e.g. variable-length lookbehind in older engines). The error often points near the first `(` that cannot be parsed.

Balance parentheses

Every opening `(` needs a closing `)`. Escape literal parentheses in text with `\(` and `\)` when you mean literal characters, not groups.

Named groups in JS

Use `(?<name>...)` for named captures. Anonymous groups are `( ... )`. Non-capturing groups use `(?: ... )` when you do not need the match index stored.

Test incrementally

Build complex patterns in the regex tester from left to right. Add one group at a time and run against sample text so the first failing token is obvious.

Related tools

Related guides