Hi,

R uses \ as a metacharacter, so you need a non-intuitive number of \:


mystring <- "Man\\Woman"
# \\ is a metacharacter and a \, so it's equivalent to \ in normal text
sub("\\\\", "/", mystring)


Sarah


On Tue, Jun 3, 2014 at 2:03 PM, Adrian Dușa <dusa.adr...@unibuc.ro> wrote:
> Dear All,
>
> I should be knowing this, but not get it right... For a string like this:
>
> "Man\Woman"
>
> I would like to detect the escape character "\" and replace it with "/".
>
> Tried various ways using gsub(), but don't get it right yet. Any suggestion
> would be highly welcomed...
>
> Thank you,
> Adrian
>

-- 
Sarah Goslee
http://www.functionaldiversity.org

______________________________________________
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