Unicode Property Without /u

Identifier: regex.lint.unicode.propertyWithoutU

When it triggers: A Unicode property (\p{…} or \P{…}) is used, and the pattern has neither /u nor (*UTF). The property then reads one byte at a time, as a code point below 256, so it covers only the first 256 code points.

Example:

// ERROR: "é" is the bytes \xC3 \xA9, and \xA9 is no letter
preg_match('/^\p{L}+$/', 'é');   // 0

// PREFERRED
preg_match('/^\p{L}+$/u', 'é');  // 1

Fix: Add /u.


Try it. Open /^\p{L}+$/ in the playground: the finding is in the Diagnostics tab.

Edit on GitHub Feedback