
Last chance! 50% off unlimited learning
Sale ends in
str_split(string, pattern, n=Inf)
regex
for details. If NA
, returns original string.
If ""
splistring
. pattern
should be a single
pattern, i.e. a character vector of length one.str_split_fixed
for fixed number of splitsfruits <- c(
"apples and oranges and pears and bananas",
"pineapples and mangos and guavas"
)
str_split(fruits, "and ")
# Specify n to restrict the number of possible matches
str_split(fruits, "and ", n = 3)
str_split(fruits, "and ", n = 2)
# If n greater than number of pieces, no padding occurs
str_split(fruits, "and ", n = 5)
Run the code above in your browser using DataLab