Tag: regex
-
How do I split a string by a character without ignoring trailing split-characters?
7 I have a string similar to the following my_string <- "apple,banana,orange," And I want to split by , to produce the output: list(c(‘apple’, ‘banana’, ‘orange’, "")) I thought strsplit would accomplish this but it treats the trailing ‘,’ like it doesn’t exist my_string <- "apple,banana,orange," strsplit(my_string, split = ‘,’) #> [[1]] #> [1] "apple"…