quotemeta | R Documentation |
This is an implementation of Perl's quotemeta
operator. It is
meant for escaping any characters that might have special meanings
in a PCRE.
quotemeta(string)
string |
The string to escape |
string
, with all non-word characters escaped with backslashes.
Note that this strategy does not work for R's own regular
expression syntax, so you should specify perl = TRUE
, or an
equivalent option, when using this to construct a regular
expression.
s <- "A (string) with [many] regex *characters* in it." grepl(s, s, perl = TRUE) quotemeta(s) # After escaping, the string matches itself. grepl(quotemeta(s), s, perl = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.