From: "Hanmac (Hans Mackowiak)" Date: 2013-06-11T21:45:30+09:00 Subject: [ruby-core:55434] [ruby-trunk - Bug #8512] gsub() works incorrect Issue #8512 has been updated by Hanmac (Hans Mackowiak). =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, 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 ---------------------------------------- Bug #8512: gsub() works incorrect https://bugs.ruby-lang.org/issues/8512#change-39860 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/