I have a string say \"a.b\" and I want to replace \".\" with \"_\".
gsub(\".\",\"_\",\"a.b\")
doesn\'t work as . matches all characters.>
. matches any character. Escape . using \ to match . literally.
.
\
\ itself is also should be escaped:
> gsub("\\.", "_", "a.b") [1] "a_b"