Following up on this question, I have another example where I cannot use the accepted answer.
Again, I want to find each of the exact group elements in the
group
+ is a special character in regex. You will need "\+" to escape the special character.
+
new_group <- gsub("\\+",replacement = "\\\\+",x =groups)
Also, "|" in grep serves like "or".
new_group1 <- paste0(new_group,collapse = "|") grep(pattern = new_group1,x = labs,value = T)