Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

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.

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.

Value

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

Author(s)

Charles Dupont
Department of Biostatistics
Vanderbilt University

See Also

Examples

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

escapeBS(string)

Hmisc

Harrell Miscellaneous

v4.5-0
GPL (>= 2)
Authors
Frank E Harrell Jr <fh@fharrell.com>, with contributions from Charles Dupont and many others.
Initial release
2021-02-27

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.