Re: [Rd] gsub + backslashes

2006-04-24 Thread Bill Dunlap
On Mon, 24 Apr 2006, Prof Brian Ripley wrote: > On Mon, 24 Apr 2006, Torsten Hothorn wrote: > > > > > Dear developeRs, > > > > I thought that backslashes can be escaped in the usual way (and I think I > > did this before) but I can't see why > > > > R> gsub("\\", "x", "\alpha") > > Error in gsub(p

Re: [Rd] gsub + backslashes

2006-04-24 Thread Prof Brian Ripley
On Mon, 24 Apr 2006, Torsten Hothorn wrote: > > Dear developeRs, > > I thought that backslashes can be escaped in the usual way (and I think I > did this before) but I can't see why > > R> gsub("\\", "x", "\alpha") > Error in gsub(pattern, replacement, x, ignore.case, extended, fixed, > useBytes)

Re: [Rd] gsub + backslashes

2006-04-24 Thread Gabor Grothendieck
\ is a special character in regular expressions so you need to escape it as \\ but putting \\ between quotes give you only \ so you need to get \\. Any of these would work: gsub("", "x", "\\alpha") gsub("[\\]", "x", "\\alpha") sub(".", "x", "\\alpha") # assumes \ is first character gsub(

Re: [Rd] gsub + backslashes

2006-04-24 Thread Simon Urbanek
On Apr 24, 2006, at 10:23 AM, Torsten Hothorn wrote: > > Dear developeRs, > > I thought that backslashes can be escaped in the usual way (and I > think I > did this before) but I can't see why > > R> gsub("\\", "x", "\alpha") > Error in gsub(pattern, replacement, x, ignore.case, extended, fixed

[Rd] gsub + backslashes

2006-04-24 Thread Torsten Hothorn
Dear developeRs, I thought that backslashes can be escaped in the usual way (and I think I did this before) but I can't see why R> gsub("\\", "x", "\alpha") Error in gsub(pattern, replacement, x, ignore.case, extended, fixed, useBytes) : invalid regular expression '\' gives an error.