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

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

______________________________________________
R-help@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.

Reply via email to