fork(1) download
  1. x = c('One,,', 'Two!!!', '!!!???,,,')
  2. gr <- gregexpr("[[:punct:]]+", x, ignore.case = TRUE)
  3. mat <- regmatches(x, gr)
  4. regmatches(x, gr) <- lapply(mat, gsub, pattern="(.)", replacement="\\\\\\1")
  5. cat(x, sep="\n")
  6.  
Success #stdin #stdout 0.15s 178496KB
stdin
Standard input is empty
stdout
One\,\,
Two\!\!\!
\!\!\!\?\?\?\,\,\,