I\'m not new to R but I am relative new to regular expression.
A similar question can be found in here.
An example is if I use
> strsplit(
You can use stri_split
function from stringi
package
x <- "USA,UK,Poland"
stri_split_fixed(x,",") # standard split by comma
[[1]]
[1] "USA" "UK" "Poland"
stri_split_fixed(x,",",n = 2) # set the max number of elements
[[1]]
[1] "USA" "UK,Poland"
Unfortunately there is no parameter to change the starting point for splitting (from begin/end) but we can handle this another way - using stri_reverse
stri_split_fixed(stri_reverse(x),",",n = 2) #reverse
[[1]]
[1] "dnaloP" "KU,ASU"
stri_reverse(stri_split_fixed(stri_reverse(x),",",n = 2)[[1]]) #reverse back
[1] "Poland" "USA,UK"
stri_reverse(stri_split_fixed(stri_reverse(x),",",n = 2)[[1]])[2:1] #and again :)
[1] "USA,UK" "Poland"