Skip to content
Prev 20405 / 63424 Next

gsub + backslashes

On Mon, 24 Apr 2006, Prof Brian Ripley wrote:

            
Also, unless fixed==TRUE, you need to double the backslash
in the replacement string (because \\<digit|U|L> has a special
meaning when fixed!=TRUE):

   > cat(gsub("/", "\\\\", "C:/Program Files/R"),"\n")
   C:\Program Files\R
   > cat(gsub("/", "\\", "C:/Program Files/R", fixed=T), "\n")
   C:\Program Files\R

----------------------------------------------------------------------------
Bill Dunlap
Insightful Corporation
bill at insightful dot com
360-428-8146

 "All statements in this message represent the opinions of the author and do
 not necessarily reflect Insightful Corporation policy or position."