From: shyouhei@... Date: 2018-05-29T05:17:13+00:00 Subject: [ruby-core:87287] [Ruby trunk Bug#14791][Rejected] String.sub wrong parsing of replacement with capturing group Issue #14791 has been updated by shyouhei (Shyouhei Urabe). Status changed from Open to Rejected Let me reject; this is not a bug. ---------------------------------------- Bug #14791: String.sub wrong parsing of replacement with capturing group https://bugs.ruby-lang.org/issues/14791#change-72277 * Author: churib (Timo Grodzinski) * Status: Rejected * Priority: Normal * Assignee: * Target version: * ruby -v: ruby 2.3.3p222 (2016-11-21) [x86_64-linux-gnu] * Backport: 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN ---------------------------------------- ~~~ ruby irb(main):001:0> "abc".sub(/(b)/, '#\1#') # works => "a#b#c" irb(main):002:0> "abc".sub(/(b)/, '\\1') # doesn't works, should be "a\bc" => "abc" irb(main):003:0> "abc".sub(/(b)/, '\\\1') # doesn't works, should be "a\\bc" => "a\\1c" irb(main):004:0> "abc".sub(/(b)/, "\\1") # works => "abc" irb(main):005:0> "abc".sub(/(b)/, "\\\\1") # doesn't works, should be "a\bc" => "a\\1c" irb(main):006:0> "abc".sub(/(b)/, '\ \1') # works => "a\ bc" ~~~ -- https://bugs.ruby-lang.org/ Unsubscribe: