R/bstr_detect.R

Defines functions bstr_detect

Documented in bstr_detect

#' Detect the presence or absence of a pattern in a bstr object
#' @inheritParams class_bstr
#' @param negate If TRUE, return non-matching elements.
#' @export
#' @examples
#' bstr_detect(c("apple", "banana"), "n")
#' bstr_detect(c("apple", "banana"), c("a", "n"))
#'
bstr_detect <- function(bstrobj, pattern, negate = FALSE) {
  bstrobj <- as_bstr(bstrobj)
  stringr::str_detect(bstrobj, pattern, negate)
}
t-arae/bstringr documentation built on March 18, 2021, 3:08 a.m.