#' Espace special characters in regex
#'
#' @param str A character vector
#' @return Initial vector with special
#' characters escaped
str_to_regex <- function(str){
special_characters <- c("^", "$", ".",
"|", "?", "*",
"+", "(", ")",
"[", "]" ,"{", "}")
return(
mgsub(special_characters, paste0("\\", special_characters),
str)
)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.