re_escape {re}R Documentation

Escape special characters

Description

re_escape escapes all special characters in a string. This function is useful when you want to treat a string literally in a regular expression context, escaping characters that would otherwise be interpreted as special regex operators.

Usage

re_escape(pattern)

Arguments

pattern

A character vector where each element is a string in which special regex characters are to be escaped.

Value

A character vector of the same length as pattern.

See Also

Python re.escape() documentation

Examples

re_escape("a[bc].*d?")
re_escape(".^$|*+?{}[]()")

[Package re version 0.1.0 Index]