Escape Strings From Parsing

Usage

escape(pattern)

Arguments

pattern
A character string that should not be parsed.

Value

Returns a character vector of the class "escape" and "character".

Description

Escape literal beginning at (@) strings from qdapRegex parsing.

Details

Many qdapRegex functions parse pattern strings beginning with an at character (@) and comparing against the default and supplemental (regex_supplement) dictionaries. This means that a string such as "@before_" will be returned as "\\w+?(?= ((%s|%s)\\b))". If the user wanted to use a regular expression that was literally "@before_" the escape function classes the character string and tells the qdapRegex functions not to parse it (i.e., keep it as a literal string).

Examples

escape("@rm_caps")
[1] "@rm_caps" attr(,"class") [1] "escape" "character"
x <- "...character vector. Default, \\code{@rm_caps} uses..." rm_default(x, pattern = "@rm_caps")
[1] "...character vector. Default, \\code{@rm_caps} uses..."
rm_default(x, pattern = escape("@rm_caps"))
[1] "...character vector. Default, \\code{} uses..."