A regular expression ends in a reluctant quantifier, which then matches as little as possible: nothing

tx0/php:regex-lazy-at-endrecommendedwarningreliability/strings-and-regexdepth fastbug

What it finds

A regular expression ends in a reluctant quantifier, which then matches as little as possible: nothing

Example from the rule's tests
<?php$a = preg_match('/id=(.*?)/', $url, $m);tx0 reports: matches nothing$b = preg_replace('/<!--.*?/', '', $html);tx0 reports: matches nothing$c = preg_match('/id=(.*?)&/', $url, $m);$d = preg_match('/id=(.*?)$/', $url, $m);$e = preg_match('/id=(.+?)/', $url, $m);$f = preg_match('/id=(.*?)/U', $url, $m);
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

Turn it on, off or suppress it

The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/php:regex-lazy-at-end" = "warning"

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-lazy-at-end] reason="..."

tx0 explain tx0/php:regex-lazy-at-end shows the same in the terminal. Found a false positive? Report it.