Splitting strings help

Hi, @trent, please see FAQ: What's a reproducible example (`reprex`) and how do I do one?. They are very helpful.

I have probably misunderstood the question as to what is wanted and what is unwanted. Assuming what is wanted is "(A01AB04")

library(stringr)
vec <- c("Amphotericin B (A01AB04)","Nystatin,(A07AA02)","Clotrimazole,(G01AF02)","Doxycycline,(J01AA02)","Ampicillin,(J01CA01)")
pattern <- "\\(.*\\)$"
str_extract(vec,pattern)
#> [1] "(A01AB04)" "(A07AA02)" "(G01AF02)" "(J01AA02)" "(J01CA01)"

Created on 2020-02-19 by the reprex package (v0.3.0)