You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
stri_sub(string, from, to = -1) is often used to get the end of a string.
As shown in the following reprex, if from = -2 or from = -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(). tidyverse/stringr#512
I think we need a function to get the end of the string or some option for stri_sub().
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.
stri_sub(string, from, to = -1)
is often used to get the end of a string.As shown in the following reprex, if
from = -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()
.tidyverse/stringr#512
I 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
The text was updated successfully, but these errors were encountered: