I have a use case where
x <- "test - hello\r\n 1...124"
and I would like to obtain "test - hello 1...124
. I am aware that I can use "gsub("[\r\n]", "", x)"
for this specific case. However, I am wondering how to more generally remove any backslash followed by any symbol (e.g. using something like "\."
and escaping the backslash). Examples that did not work are
gsub("\.", "", x) # error
gsub("\\.", "", x) # escapes "."?
gsub("\\\.", "", x) # error
gsub("\\\\.", "", x) # ??
...
Also I would be very thankful for an explanation as to why this is not working.