findprev
/findlast
with empty search string
#39940
Labels
bug
Indicates an unexpected problem or unintended behavior
help wanted
Indicates that a maintainer wants help on an issue or pull request
search & find
The find* family of functions
strings
"Strings!"
I think the behavior of
findprev
andfindlast
with an empty search string is wrong:For non-empty search strings,
findnext(needle, haystack, i)
returns a range whose start is at leasti
. Similarly,findprev(needle, haystack, i)
returns a range whose stop is at mosti
. Consider the following example:However, this is not the case for an empty
needle
:I think the
findprev
behavior is wrong, we should havefindprev("", "abc", 2) === 3:2
.The same holds for
findlast
: I think we should havefindlast("", "aaaa") === 5:4
instead of4:3
.The text was updated successfully, but these errors were encountered: