R/grepE.R

Defines functions grepE

Documented in grepE

#' Grep an Exact Pattern
#'
#' Search for an exact pattern, with no character before or after the pattern.
#' @param pattern The search term.
#' @param x The object to search against.
#' @param ... Other standard arguments - see '?grep' for more details.
#' @keywords grep search exact
#' @export
#' @examples
#' grepE(pattern = 'test', x = c('notest', 'testtwo', 'test', 'est'))
#' [1] 3


grepE <- function(pattern, x, ignore.case = FALSE, perl = FALSE, value = FALSE, fixed = FALSE, useBytes = FALSE, invert = FALSE) {

  grep(pattern = paste0('^', pattern, '$'),
       x = x,
       ignore.case = ignore.case,
       perl = perl,
       value = value,
       fixed = fixed,
       useBytes = useBytes,
       invert = invert)

}
danjamesadams/Dantools documentation built on Aug. 24, 2019, 6:15 p.m.