R/is_in_patterns.R

Defines functions is_in_patterns

#' Is there at least one regular expression having a match with the line?
#' @param line a line of text
#' @param patterns one or more regular expression patterns
#' @return TRUE if there is at least one match found
#' @author Richèl J.C. Bilderbeek
#' @noRd
is_in_patterns <- function(line, patterns) {

  for (pattern in patterns) {
    if (!is_one_na(stringr::str_match(string = line, pattern = pattern)[1, 1]) # nolint beautier function
    ) {
      return(TRUE)
    }
  }
  FALSE
}
ropensci/beautier documentation built on March 12, 2019, 8:27 p.m.