x <- c("--A--", "--B--", "--ABC--", "--AC--", "Z")
txt_grepl(x, pattern = c("A", "C"), FUN = all)
txt_grepl(x, pattern = c("A", "C"), FUN = any)
txt_grepl(x, pattern = c("A", "C"), FUN = sum)
data.frame(x = x,
A_and_C = txt_grepl(x, pattern = c("A", "C"), FUN = all),
A_or_C = txt_grepl(x, pattern = c("A", "C"), FUN = any),
A_C_n = txt_grepl(x, pattern = c("A", "C"), FUN = sum))
txt_grepl(x, pattern = "A|C")
Run the code above in your browser using DataLab