R/escapeRegex.R

Defines functions escapeRegex

Documented in escapeRegex

#' escapeRegex
#' 
#' Escapes all symbols in a string which have a special meaning in regular
#' expressions.
#' 
#' 
#' @param x String or vector of strings that should be escaped.
#' @return The escaped strings.
#' @author Jan Philipp Dietrich
#' @seealso \code{\link[base]{grep}}
escapeRegex <- function(x) 
{
    return(gsub("([.|()\\^{}+$*?]|\\[|\\])", "\\\\\\1", x))
}
pik-piam/magclass documentation built on May 2, 2024, 5:13 p.m.