Project

General

Profile

Actions

Bug #14791

closed

String.sub wrong parsing of replacement with capturing group

Bug #14791: String.sub wrong parsing of replacement with capturing group

Added by churib (Timo Grodzinski) over 7 years ago. Updated over 7 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
ruby -v:
ruby 2.3.3p222 (2016-11-21) [x86_64-linux-gnu]
[ruby-core:87278]

Description

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" 
Actions

Also available in: PDF Atom