Using certain features of regular expressions, it is possible to create regular expressions that can never match or contain subpatterns that can never match. Since a pattern or sub-pattern that can never match any input is pointless, this is a sign that the pattern does not work as intended and needs to be fixed.

This rule finds some such regular expressions and subpatterns, specifically ones that meet one of the following conditions:

Noncompliant Code Example

Boundaries

$[a-z]*^

Backreference

\1(.)

Compliant Solution

Boundaries

^[a-z]*$

Backreference

(.)\1