A possessive quantifier takes the characters that the next part of the regular expression needs, so it never matches
What it finds
.*+x never matches: a possessive quantifier takes as much as it can and gives nothing back, so .*+ eats the x too and the pattern fails at the x. A possessive quantifier is only safe when what follows cannot match what it repeats.
Reported is an unbounded possessive quantifier on a single character, class or ., followed directly by a character that it also matches.
From the rule's source, regex_patterns.rs.
val never = Regex(".*+x")tx0 reports: a possessive quantifier takes the character that follows itval digits = Regex("\\d++5")tx0 reports: never matchesval fine = Regex("[a-z]*+1") 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/kotlin:regex-possessive-starves" = "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/kotlin:regex-possessive-starves] reason="..."tx0 explain tx0/kotlin:regex-possessive-starves shows the same in the terminal. Found a false positive? Report it.