string <- "The qu!ck, brown fox jumps over the `lazy` d*g!"gsub(pattern = "([[:punct:]])",replacement="\\\\\\1",string)
Standard input is empty
[1] "The qu\\!ck\\, brown fox jumps over the \\`lazy\\` d\\*g\\!"
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!