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

escape_special

Escape special characters


Description

Prefix the special characters with a blackslash to make them literal characters.

Usage

escape_special(x, escape_brace = TRUE)

Arguments

x

A character vector.

escape_brace

A logical value indicating if opening braces should be escaped. If using R's internal PRCE engine or stringi's ICU engine, you want this. If using the perl engine, you don't.

Value

A character vector, with regex meta-characters escaped.

Note

Special characters inside character classes (except caret, hypen and closing bracket in certain positions) do not need to be escaped. This function makes no attempt to parse your regular expression and decide whether or not the special character is inside a character class or not. It simply escapes every value.

Examples

escape_special("\\ ^ $ . | ? * + ( ) { } [ ]")

rebus.base

Core Functionality for the 'rebus' Package

v0.0-3
Unlimited
Authors
Richard Cotton [aut, cre]
Initial release
2017-04-25

We don't support your browser anymore

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