R/is_in_patterns.R

Defines functions is_in_patterns

Documented in 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
#' @export
is_in_patterns <- function(line, patterns) {

  for (pattern in patterns) {
    if (
      !is_one_na(
        stringr::str_match(string = line, pattern = pattern)[1, 1]
      )
    ) {
      return(TRUE)
    }
  }
  FALSE
}

Try the beautier package in your browser

Any scripts or data that you put into this service are public.

beautier documentation built on Nov. 2, 2023, 5:08 p.m.