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 Aug. 15, 2022, 9:05 a.m.