fork download
  1. DirtyChars = c(',', '.', ';', '?', '/', '\\', '`', '[', ']', '"', ':', '>', '<', '|', '-', '_', '=', '+', '(', ')', '^', '{', '}', '~', '\'', '*', '&', '%', '$', '!', '@', '#')
  2. s <- "#w$o;r&d^$"
  3. escape_for_char_class <- function(s) {gsub("([]^\\\\-])", "\\\\\\1", s)}
  4. pattern <- paste0("[", escape_for_char_class(paste(DirtyChars, collapse="")), "]")
  5. ## [1] "[,.;?/\\\\`[\\]\":><|\\-_=+()\\^{}~'*&%$!@#]"
  6. gsub(pattern, "", s, perl=TRUE)
Success #stdin #stdout 0.29s 39460KB
stdin
Standard input is empty
stdout
[1] "word"