escapeRegex

Escapes any characters that would have special meaning in a reqular expression.

Escapes any characters that would have special meaning in a reqular expression.

Keywords
character , programming , manip
Usage
escapeRegex(string)
Arguments
string
string being operated on.
Details

escapeRegex will escape any characters that would have special meaning in a reqular expression. For any string grep(regexpEscape(string), string) will always be true.

Value

The value of the string with any characters that would have special meaning in a reqular expression escaped.

Note

Note that this function was copied literally from the Hmisc package (to prevent importing the entire package for one line of code).

See Also

grep, Hmisc, http://biostat.mc.vanderbilt.edu/wiki/Main/Hmisc, https://github.com/harrelfe/Hmisc

Aliases
  • escapeRegex
  • escapeBS
Examples
string <- "this\\(system) {is} [full]."
escapeRegex(string)

Documentation reproduced from package userfriendlyscience, version 0.6-1, License: GPL (>= 2)

Community examples

Looks like there are no examples yet.