Closed UchidaMizuki closed 1 year ago
This is a boundary case, this behaviour is intended.
It if for compatibility with stri_sub<-
(the replacement version of the operator), which allows prepending a substring at the start of a given string.
In other words, think of 0 as 1.
Thanks. I see that special care is needed to get the tail of the string.
stri_sub(string, from, to = -1)
is often used to get the end of a string. As shown in the following reprex, iffrom = -2
orfrom = -1
, the last two or one character can be obtained, respectively.However, when
from = 0
, all strings are retrieved, not just""
. (I think this is because zeros are treated as positive numbers.)This somewhat unpredictable behavior causes the following bug in
stringr::str_trunc()
. https://github.com/tidyverse/stringr/issues/512I think we need a function to get the end of the string or some option for
stri_sub()
.Created on 2023-06-26 with reprex v2.0.2