[R] How to get the string '\'?

Linlin Yan yanlinlin82 at gmail.com
Mon Nov 16 00:52:09 CET 2009


Regular expression needs double the '\' again, so try this:
gsub('/','\\\\',string)

On Mon, Nov 16, 2009 at 7:35 AM, Peng Yu <pengyu.ut at gmail.com> wrote:
> My question was from replacing a pattern by '\\'. How to replace '/'
> in string by '\'?
>
> string='abc/efg'
> gsub('/','\\',string)
> ______________________________________________
> 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.
>




More information about the R-help mailing list