x <- c("DECIMAL", "DECIMAL(14,5)", "RAND(1)")sub("^.*?(\\(.*\\))?$", "\\1", x, perl=TRUE)
Standard input is empty
[1] "" "(14,5)" "(1)"
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!