Issue #8512 has been updated by phluid61 (Matthew Kerwin).


For the record, you can also use the hash replacement form, because that doesn't use regexp back-references:

  "\\".gsub("\\", "\\"=>"\\\\")  #=> "\\\\"

----------------------------------------
Bug #8512: gsub() works incorrect 
https://bugs.ruby-lang.org/issues/8512#change-39863

Author: galnaktar (Oleg K)
Status: Rejected
Priority: Normal
Assignee: 
Category: 
Target version: 
ruby -v: ruby 2.0.0p195 (2013-05-14) [i386-mingw32]
Backport: 1.9.3: UNKNOWN, 2.0.0: UNKNOWN


irb(main):005:0> "\\".gsub("\\", "\\\\").length 
=> 1 
irb(main):006:0> "\\".gsub("\\", "XX").length 
=> 2

bug is duplicated with rejected bug #8511


-- 
http://bugs.ruby-lang.org/