Skip to content

replace double backslash with singel backslash

7 messages · jim holtman, Michael Friendly, Gene Leynes +2 more

#
I want to replace \\ with \ in:
str <-
"C:\\DOKUME~1\\u0327336\\LOKALE~1\\Temp\\RtmpQ5NJ8X\\TIRIS_PICS\\1_Img.jpg"

and tried:
gsub("\\\\", "\\", str)

but this removes the \\ without replacing them by \

Any help much appreciated,
Kay

-----
------------------------
Kay Cichini
Postgraduate student
Institute of Botany
Univ. of Innsbruck
------------------------

--
View this message in context: http://r.789695.n4.nabble.com/replace-double-backslash-with-singel-backslash-tp3989434p3989434.html
Sent from the R help mailing list archive at Nabble.com.
#
what is the problem that you are trying to solve?  you need the double \\ since they have a special meaning in quoted strings.  in this case they represent a since backslash.  if you really had a single one, then something like this '\n' would be a carriage return.  

Sent from my iPad
On Nov 4, 2011, at 5:35, Kay Cichini <Kay.Cichini at uibk.ac.at> wrote:

            
#
On 11/4/2011 5:35 AM, Kay Cichini wrote:
You may be able to avoid this simply by using forward slashes in path 
names. Otherwise,
?normalizePath
may help.
4 days later
#
Thanks,
that helped!

Yours,
Kay

Zitat von Gene Leynes <gleynes+r at gmail.com>: