Suspicious ASCII Ranges

Identifier: regex.lint.charclass.suspiciousRange

When it triggers: A character range spans the ASCII gap between Z and a (e.g. [A-z]), which includes [ \ ] ^ _ .

Example:

// WARNING: Includes non-letters between Z and a
preg_match('/[A-z]/', $input);

// PREFERRED: Use two ranges
preg_match('/[A-Za-z]/', $input);

Fix: Split into [A-Z] and [a-z], or combine as [A-Za-z].


Try it. Open /[A-z]/ in the playground: the finding is in the Diagnostics tab.

Edit on GitHub Feedback