SyntaxError: incomplete quantifier in regular expression
The JavaScript exception "incomplete quantifier in regular expression" occurs when a regular expression pattern contains a{, but it does not start a validquantifier.
In this article
Message
SyntaxError: Invalid regular expression: /1{/u: Incomplete quantifier (V8-based)SyntaxError: incomplete quantifier in regular expression (Firefox)SyntaxError: Invalid regular expression: incomplete {} quantifier for Unicode pattern (Safari)Error type
SyntaxErrorWhat went wrong?
A{ character in a regular expression pattern starts aquantifier. A valid quantifier is in the form{n},{n,}, or{n,m}, wheren andm are non-negative integers andm is not less thann. If the{ character does not start a valid quantifier, aSyntaxError occurs.
In Unicode-unaware mode, this syntax causes the{ to become a literal character instead of generating an error, but this is adeprecated syntax and you should not rely on it.
Examples
>Invalid cases
js
/1{/u;/1{a}/u;/1{}/u;/1{1,2,3}/u;/1{1, 2}/u;Valid cases
js
/1{1}/u;/1{1,}/u;/1{1,2}/u;