From: Hugh Sasse Staff Elec Eng Date: 2001-03-06T21:33:03+09:00 Subject: [ruby-talk:12122] Re: String.gsub(), & RCR On Tue, 6 Mar 2001, Mike Bowler wrote: > > puts inputString.gsub(/'(.+)'/, "\"\\1\"") [...] > > Thanks! That works beautifully! > > I'm a little confused about the solution. Why would we need the extra \ > before the \1 just because an escaped quote was nearby? Is this just That is not the reason. Double quotes allow backslashes to quote things. So you can take a double quoted string to mean: The contents of this string is what I get after interpreting the backslashes expanding variables so "\"\\1\n#{x}" for example would become the chars "\1#{x} which is, if x is 1, "\11 and these chars are passed to gsub to give "1 So it is not the quotes, \n would be treated specially, too. See syntax.html#expression in the 1.4 manual. > > Mike > mbowler@GargoyleSoftware.com > RCR: I'd like to see a string type where NO backslashes at all are treated specially, to avoid this kind of confusion. We have %x for Executable, what about %X for XML-style so one could have %XWe can talk about string and even but the end is here: where ... could be This might be separable into 2 RCRs in fact -- the non-quoting string and extension of % syntax to allow this type of tagging, but dong it as one is easier. Hugh