x <- "A(B)C"library(stringr)str_extract_all(x, "\\([^()]*\\)|[^()]+")
Standard input is empty
[[1]] [1] "A" "(B)" "C"
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!