Duplicate Character Class Elements
Identifier: regex.lint.charclass.duplicateChars
When it triggers: A character class contains an element that is fully covered by another element (e.g., \d plus 0-9).
Example:
// WARNING: \d already includes 0-9
preg_match('/[\d0-9]/', $input);
// WARNING: \w already includes A-Z
preg_match('/[\wA-Z]/', $input);
// PREFERRED: Remove the redundant element
preg_match('/[\d]/', $input);
preg_match('/[\w]/', $input);
Fix: Remove the redundant character class element.
Try it. Open /[\d0-9]/ in the playground: the finding is in the Diagnostics tab.
Edit on GitHub
Feedback