Skip to content

Instantly share code, notes, and snippets.

@arbelt
Created January 17, 2017 22:25
Show Gist options
  • Save arbelt/f3bcc00edba8a508ba813b4caa91558a to your computer and use it in GitHub Desktop.
Save arbelt/f3bcc00edba8a508ba813b4caa91558a to your computer and use it in GitHub Desktop.
library(stringr)
library(purrr)
match_multiple <- function(strings, patterns){
match_fns <- map(
as.list(patterns),
~ partial(str_detect, pattern = ., .lazy = FALSE, .first = FALSE))
reduce(invoke_map(match_fns, list(list(strings))), `|`)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment