I am using str_match
from the stringr
package to capture text in between brackets.
library(stringr)
strs = c("P5P (abcde) + P5P (fghij)", "Glcext (abcdef)")
str_match(strs, "\\(([a-z]+)\\)")
gives me only the matches "abcde"
and "abcdef"
. How can I capture the "fghij"
as well with still using the same regex for both strings?