R/regexpEscape.s

Defines functions escapeRegex escapeBS

Documented in escapeBS escapeRegex

escapeBS <- function(string) {
  gsub('\\\\', '\\\\\\\\\\', string)
}

escapeRegex <- function(string) {
  gsub('([.|()\\^{}+$*?]|\\[|\\])', '\\\\\\1', string)
}

Try the Hmisc package in your browser

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

Hmisc documentation built on Sept. 12, 2023, 5:06 p.m.