R/text_detect.R

Defines functions text_grepl text_detect.default text_detect

Documented in text_detect text_detect.default text_grepl

#' generic function to test if a regex can be found within a string
#' @param string text to be searched through
#' @param pattern regex to look for
#' @param ... further arguments passed through to \link[base]{grep}
#' @export
text_detect <- function(string, pattern, ...){
  UseMethod("text_detect")
}


#' text_detect default method
#' @rdname text_detect
#' @method text_detect default
#' @export
text_detect.default <- function(string, pattern, ...){
  grepl(pattern=pattern, x=string, ...)
}



#' generic function to test if a regex can be found within a string
#' @rdname text_detect
#' @export
text_grepl <- function(string, pattern, ...){
  UseMethod("text_detect")
}

Try the stringb package in your browser

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

stringb documentation built on Jan. 26, 2021, 1:07 a.m.