Find regex boundaries that can never match
ProprietaryMarks a regular expression passed to Pattern.compile, Pattern.matches, String.matches, String.split, String.replaceAll or String.replaceFirst when a boundary in it can never match: a ^ or \A that comes after something that has to consume input, as in a^, or a $, \Z or \z that comes before something that has to consume input, as in $b. A boundary next to an optional part, as in a*^ or $b?, gets a different message, because it only matches when that part is empty. That second case is not marked when the boundary is inside an alternation. For a ^ or \A in a lookbehind only what the lookbehind holds before it counts, and for a $, \Z or \z in a lookahead only what the lookahead holds after it. $ and \Z also match in front of a final line terminator, so after them only input that cannot be a line terminator counts: characters written as themselves, \d, \w, . without (?s), and classes of letters and digits. Not inspected: ^ and $ in a pattern that sets (?m), a boundary checked across a $ or \Z in a string literal that holds a unicode, octal, \s or \' escape, patterns that use (?x), patterns compiled with a flags argument other than 0, and patterns that are not a single string literal. Test sources are not searched.
io. moderne. staticanalysis. FindUnmatchableRegexBoundarymod run . --recipe= io. moderne. staticanalysis. FindUnmatchableRegexBoundaryInstall it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.