Issue #8512 has been updated by galnaktar (Oleg K).


Hanmac (Hans Mackowiak) wrote:
> =begin
> 
> the docs says:
> 
> ((*If replacement is a String it will be substituted for
> the matched text. It may contain back-references to the pattern's capture
> groups of the form \\\d, where d is a group number, or \\\k<n>, where n is
> a group name. If it is a double-quoted string, both back-references must be
> preceded by an additional backslash.*)) 
> 
> so you need more "\" in your string
> =end

Thanks for the explanation.
----------------------------------------
Bug #8512: gsub() works incorrect 
https://bugs.ruby-lang.org/issues/8512#change-39862

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/