pageClass | sidebarDepth | title | description | since |
---|---|---|---|---|
rule-details |
0 |
regexp/no-trivially-nested-quantifier |
disallow nested quantifiers that can be rewritten as one quantifier |
v0.9.0 |
💼 This rule is enabled in the ✅ plugin:regexp/recommended
config.
🔧 This rule is automatically fixable by the --fix
CLI option.
disallow nested quantifiers that can be rewritten as one quantifier
In some cases, nested quantifiers can be rewritten as one quantifier (e.g. (?:a{1,2}){3}
-> a{3,6}
).
/* eslint regexp/no-trivially-nested-quantifier: "error" */
/* ✓ GOOD */
var foo = /(a{1,2})+/; // the rule won't touch capturing groups
var foo = /(?:a{2})+/;
/* ✗ BAD */
var foo = /(?:a{1,2})+/;
var foo = /(?:a{1,2}){3,4}/;
var foo = /(?:a{4,}){5}/;
Nothing.
This rule was introduced in eslint-plugin-regexp v0.9.0