# regexp/no-useless-quantifier

disallow quantifiers that can be removed

  • ⚙️ This rule is included in "plugin:regexp/recommended".
  • 🔧 The --fix option on the command line (opens new window) can automatically fix some of the problems reported by this rule.

# 📖 Rule Details

This rule reports quantifiers that can trivially be removed without affecting the pattern.

This rule only fixes constant one quantifiers (e.g. a{1}). All other reported useless quantifiers hint at programmer oversight or fundamental problems with the pattern.


  • a{1}

    It's clear that the {1} quantifier can be removed.

  • (?:a+b*|c*)?

    It might not very obvious that the ? quantifier can be removed. Without this quantifier, that pattern can still match the empty string by choosing 0 many cs in the c* alternative.

  • (?:\b)+

    The + quantifier can be removed because its quantified element doesn't consume characters.

Now loading...

# 🔧 Options


# 🚀 Version

This rule was introduced in eslint-plugin-regexp v0.10.0

# 🔍 Implementation

Last Updated: 6/25/2022, 12:32:38 PM