A regular expression used to search ends in a reluctant quantifier, which then matches as little as possible: nothing
What it finds
text.replaceAll("<!--.*?", "") removes only <!--: a reluctant quantifier matches as few characters as it can, and at the end of a pattern nothing forces it to match more, so .*? matches nothing. With a search, as in replaceAll, replaceFirst and split, the pattern needs something after the quantifier, such as -->.
Reported is a pattern given to replaceAll, replaceFirst or split that ends in a reluctant quantifier with a lower bound of 0.
From the rule's source, regex_lazy_at_end.rs.
class Comments { String strip(String html) { String a = html.replaceAll("<!--.*?", "");tx0 reports: matches nothing in a search String b = html.replaceAll("<!--.*?-->", ""); return a + b; }} 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:
[rules]
"tx0/java: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/java:regex-lazy-at-end] reason="..."tx0 explain tx0/java:regex-lazy-at-end shows the same in the terminal. Found a false positive? Report it.