Is this behavior documented anywhere:

1)
puts "fred:smith".gsub(/(\w+):(\w+)/, '\2, \1')

--output:--
smith, fred

2)
puts "abc".gsub(/a(b)(c)/, "a\2\1")

--output:--
a

The double quotes surrounding the replacement string cause the backslash
sequences to stop working.  With single quotes the backslash sequences
work.  I can't find anything in pickaxe2 about that.  .My understanding
was that double quotes allowed for more substitutions than single
quotes.  This appears to be a case where double quotes allow fewer
substitutions than single quotes.
-- 
Posted via http://www.ruby-forum.com/.