All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.sonar.l10n.php.rules.php.S5996.html Maven / Gradle / Ivy

Why is this an issue?

In regular expressions the boundaries ^ and \A can only match at the beginning of the input (or, in case of ^ in combination with the MULTILINE flag, the beginning of the line) and $, \Z and \z only at the end.

These patterns can be misused, by accidentally switching ^ and $ for example, to create a pattern that can never match.

Noncompliant code example

// This can never match because $ and ^ have been switched around
preg_match("/$[a-z]+^/", $str); // Noncompliant

Compliant solution

preg_match("/^[a-z]+$/", $str);




© 2015 - 2025 Weber Informatics LLC | Privacy Policy