Sean Zhang
2009-Dec-13 18:00 UTC
[R] how to replace a single forward slash with a double backward slash in a string?
Dear R-helpers. Can someone kindly tell me how to replace a single forward slash with double backward slash in a string? i.e., from "a/b" to "a\\b" Many thanks in advance. -Sean [[alternative HTML version deleted]]
David Winsemius
2009-Dec-13 18:08 UTC
[R] how to replace a single forward slash with a double backward slash in a string?
On Dec 13, 2009, at 1:00 PM, Sean Zhang wrote:> Dear R-helpers. > > Can someone kindly tell me how to replace a single forward slash > with double > backward slash in a string? > > i.e., from "a/b" to "a\\b"> sub("/", "\\\\","a/b") #the backslashes need to be doubled because they are the escape character. [1] "a\\b"> > Many thanks in advance. > > -Sean > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.David Winsemius, MD Heritage Laboratories West Hartford, CT