I worked on a similar problem. Advice John and Josh O'Brien did the trick. I started with this question:
library(dplyr) my_tibble <- tibble(Col1=c("ABC:Content","BCDE:MoreContent","FG:Conent:with:colons"))
Looks like:
| Col1 1 | ABC:Content 2 | BCDE:MoreContent 3 | FG:Content:with:colons
I needed to create this tibet:
| Col1 | Col2 | Col3 1 | ABC:Content | ABC | Content 2 | BCDE:MoreContent | BCDE | MoreContent 3 | FG:Content:with:colons| FG | Content:with:colons
And I did it with this code (R version 3.4.2).
my_tibble2 <- mutate(my_tibble ,Col2 = unlist(lapply(strsplit(Col1, ':',fixed = TRUE), '[', 1)) ,Col3 = gsub("^[^:]*:", "", Col1))
source share