Split strings on third white space from the right
问题 I would like to split a series of strings on the third white space from the right. The number of white spaces varies among string, but each string has at least three white spaces. Here are two example strings. strings <- c('abca eagh ijkl mnop', 'dd1 ss j, ll bb aa') I would like: [1] 'abca', 'eagh ijkl mnop' [2] 'dd1 ss j,', 'll bb aa' The closest I have been able to come is: strsplit(strings, split = "(?<=\\S)(?=\\s(.*)\\s(.*)\\s(.*)$)", perl = TRUE) which returns: [[1]] [1] "abca" " eagh"