x <- c("apple", "banana", "lemon")
multi_grepl(x, c("a" = "^[ab]", "b" = "lem"))
multi_grepl(x, c("a" = "^[ab]", "b" = "q")) # lemon not matches on either
multi_grepl(x, c("a" = "^[ab]", "b" = "e")) # apple matches "a" before "b"
multi_grepl(x, c("a" = "^[ab]", "b" = "e"), simplify = FALSE) # shows all matches
multi_grepl(x, c("^[ab]", "e")) # returned as positions
multi_grepl(x, c("^[ab]", "e"), simplify = FALSE)
Run the code above in your browser using DataLab