I'm using regular expressions in R. I am trying to pick out parenthesized content that is at the end of some strings in a character vector. I'm able to find parenthesized content when it exists, but I'm failing to excluded non-parenthesized content in inputs that don't have parens.
Example:
> x <- c("DECIMAL", "DECIMAL(14,5)", "RAND(1)")
> gsub("(.*?)(\\(.*\\))", "\\2", x)
[1] "DECIMAL" "(14,5)" "(1)"
The last 2 elements in output are correct, the first one is not. I want
c("", "(14,5)", "(1)")
The input can have anything, literally any word or number characters, before the parenthesized content.