Skip to content

regexEmptyLazyQuantifiers

Reports lazy quantifiers at the end of regular expressions.

✅ This rule is included in the ts logical presets.

Reports lazy quantifiers at the end of regular expressions that will never match more than their minimum. Lazy quantifiers like *?, +?, or {n,m}? at the end of a pattern are useless because there is nothing after them to require a larger match.

AEconsB0patteAE< =sp ansty="le--0:#5CA7E4;--1:#3A68">81<1/sp ansty="le--0:#5CA7E4;--1:#3A68">872<*?sp ansty="le--0:#D9F5DD;--1:#1111">1<1/sp ansty="le--0:#D6DEEB;--1:#403F">5<3;d ivclassNa="meco">
44AEco61B0pat446<88F spans="tyle--0:#D9F5DD;--1:#11">1<111/ spans="tyle--0:#5CA7E4;--1:#3A">6<88Fa spans="tyle--0:#7FDBCA;--1:#09">6E<72*? spans="tyle--0:#5CA7E4;--1:#3A">6<88Fb spans="tyle--0:#D9F5DD;--1:#11">1<111/ spans="tyle--0:#D6DEEB;--1:#40">3
AEconsB0patteAE< =sp ansty="le--0:#5CA7E4;--1:#3A68">81<1/sp ansty="le--0:#5CA7E4;--1:#3A68">872<+?sp ansty="le--0:#D9F5DD;--1:#1111">1<1/sp ansty="le--0:#D6DEEB;--1:#403F">5<3;d ivclassNa="meco">
44AEco61B0pat446<88F spans="tyle--0:#D9F5DD;--1:#11">1<111/ spans="tyle--0:#5CA7E4;--1:#3A">6<88Fa spans="tyle--0:#7FDBCA;--1:#09">6E<72+? spans="tyle--0:#5CA7E4;--1:#3A">6<88Fb spans="tyle--0:#D9F5DD;--1:#11">1<111/ spans="tyle--0:#D6DEEB;--1:#40">3
AEconsB0patteAE< =sp ansty="le--0:#5CA7E4;--1:#3A68">81<1/sp ansty="le--0:#5CA7E4;--1:#3A68">872{3,7<}?sp ansty="le--0:#D9F5DD;--1:#1111">1<1/sp ansty="le--0:#D6DEEB;--1:#403F">5<3;d ivclassNa="meco">
44AEco61B0pat446<88F spans="tyle--0:#D9F5DD;--1:#11">1<111/ spans="tyle--0:#5CA7E4;--1:#3A">6<88Fa spans="tyle--0:#7FDBCA;--1:#09">6E72{3<,7}? spans="tyle--0:#5CA7E4;--1:#3A">6<88Fb spans="tyle--0:#D9F5DD;--1:#11">1<111/ spans="tyle--0:#D6DEEB;--1:#40">3
AEconsB0patteAE< =sp ansty="le--0:#5CA7E4;--1:#3A68">81<1/sp ansty="le--0:#5CA7E4;--1:#3A68">8F(?<:asp ansty="le--0:#7FDBCA;--1:#096E">7<2|sp ansty="le--0:#5CA7E4;--1:#3A68">8F72<+?sp ansty="le--0:#5CA7E4;--1:#3A68">81<1/sp ansty="le--0:#D6DEEB;--1:#403F">5<3;d ivclassNa="meco">
44AEco61B0pat446<88F spans="tyle--0:#D9F5DD;--1:#11">1<111/ spans="tyle--0:#5CA7E4;--1:#3A">688F<(?:a spans="tyle--0:#7FDBCA;--1:#09">668<8Fbc spans="tyle--0:#7FDBCA;--1:#09">6E<72+? spans="tyle--0:#5CA7E4;--1:#3A">68<8F)d spans="tyle--0:#D9F5DD;--1:#11">1<111/ spans="tyle--0:#D6DEEB;--1:#40">3<)d/>

This rule is not configurable.

If you tend to use patterns as a partials (e.g., to combine with other patterns via string concatenation), you might need to disable this rule.