I want to group the words of string(given below)
text=\"Lorem,ipsum,dolor,sit,amet,consectetuer\"
like this
textNew=\"Lore
Through gsub function,
gsub
> text="Lorem,ipsum,dolor,sit,amet,consectetuer" > f <- gsub(",([^,]*)", " \\1,\\1", text, perl=TRUE) > result <- gsub(",[^,]*$", "", f, perl=TRUE) > result [1] "Lorem ipsum,ipsum dolor,dolor sit,sit amet,amet consectetuer"