x <- "abc(0)(1)%ile, def(2)(3)(4)%ile(5)%ile"library(stringr)result <- str_match(x, "\\bdef(?:\\((\\d+)\\))+%ile")result[,2]
Standard input is empty
[1] "4"
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!