subject <- "Some [string] here and [there]"gsub("\\[([^]]*)\\]", "{\\1}", subject)
Standard input is empty
[1] "Some {string} here and {there}"
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!