pattern_test<-"\\{(?:[^{}]++|(?R))*}" teststring <- "{the {dog} is {hot}},{the {cat} is {lazy}}" unlist(regmatches(teststring, gregexpr(pattern_test, teststring, perl=TRUE)))
Standard input is empty
[1] "{the {dog} is {hot}}" "{the {cat} is {lazy}}"
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!