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<newline>#{x} which is, if x is 1,
   "\1<newline>1
and these chars are passed to gsub to give
   "<what we matched><newline>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

%X<string>We can talk about string and even <string> but the end is here:</string>

where <string>...</string> could be <anything you like>
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