text <- c("TreeRULakeSunWater", "A B C D")gsub("Tree(\\w+)Lake", "Tree \n\\1 Lake", text)
Standard input is empty
[1] "Tree \nRU LakeSunWater" "A B C D"
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!