A ^ or $ in a regular expression stands where it can never match, so the pattern never matches
What it finds
A ^ or $ in a regular expression stands where it can never match, so the pattern never matches
<?php$a = preg_match('/a^b/', $s);tx0 reports: can never match$b = preg_match('/end$x/', $s);tx0 reports: can never match$c = preg_match('/a\zb/', $s);tx0 reports: can never match$d = preg_match('/a^b/m', $s);$e = preg_match('/^a|b$/', $s);$f = preg_match('/x$\n/', $s);$g = preg_match('/(^|,)a/', $s);$h = preg_match('/(?m)a$b/', $s); Turn it on, off or suppress it
The rule runs from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/php:regex-unmatchable-anchor" = "error"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/php:regex-unmatchable-anchor] reason="..."tx0 explain tx0/php:regex-unmatchable-anchor shows the same in the terminal. Found a false positive? Report it.