stringi icon indicating copy to clipboard operation
stringi copied to clipboard

stri_sub_index()

Open gagolews opened this issue 11 years ago • 3 comments

stri_subindex("abcde", 1:2) == "ab"
stri_subindex("abcde", c(1,3,5)) == "ace"
stri_subindex("abcde", c(5,5,2)) == "eeb"
stri_subindex("abcde", c(-1,-5)), == "bcd"

gagolews avatar Jun 02 '13 20:06 gagolews

also should work for logical vectors

stri_subindex("abcde", c(T,F,T,F,T) == "acd"

single vector -> vectorized w.r.t. number of characters

a list of integer or logical vectors can also be given

gagolews avatar Jun 02 '13 21:06 gagolews

This can be imitated with #30, arg. length == 1

gagolews avatar Jun 24 '15 18:06 gagolews

> stri_join_list(stri_sub_all("spam", c(4, 3, 2, 3, 1), length=1))
[1] "mapas"
> stri_join_list(stri_sub_all("spam", list(c(4, 3, 2, 3, 1), c(1, -1)), length=1))
[1] "mapas" "sm"   

gagolews avatar Feb 28 '19 15:02 gagolews