Bug #11793
Updated by nobu (Nobuyoshi Nakada) over 8 years ago
Test case: ~~~ruby puts 'ab'.gsub('a', '\\+') ~~~ '\\\\+') Expected output: ~~~ \+b ~~~ \\+b Actual output: ~~~ b ~~~ The way I understand `gsub(pattern, replacement)` gsub(pattern, replacement) when used with two string arguments is that it will perform a literal replacement, so it is quite unexpected that substituting with `\+` \\+ removes the pattern entirely. Doc: http://ruby-doc.org/core-2.2.3/String.html#method-i-gsub