Learn R Programming

Hmisc (version 4.1-0)

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

Description

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

Usage

escapeRegex(string)
escapeBS(string)

Arguments

string

string being operated on.

Value

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

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.

escapeBS will escape any backslash \ in a string.

See Also

grep

Examples

Run this code
# NOT RUN {
string <- "this\\(system) {is} [full]."
escapeRegex(string)

escapeBS(string)

# }

Run the code above in your browser using DataLab