I want to ask how can I take the position of last index of char=" | " in R
My string will be similar like below:
I have apple|Orange|banana|perry| in my bag.
Thanks,
I want to ask how can I take the position of last index of char=" | " in R
My string will be similar like below:
I have apple|Orange|banana|perry| in my bag.
Thanks,
One option is str_locate
library(stringr)
tail(str_locate_all(str1, "[|]")[[1]], 1)
With stringi
, there is a convenient function
library(stringi)
stri_locate_last_fixed(str1, '|')
str1 <- "I have apple|Orange|banana|perry| in my bag"