Project

General

Profile

Bug #11793

Updated by burnson (William Burnson) over 8 years ago

Test case: 
 puts 'ab'.gsub('a', '\\\\+') 

 Expected output: 
 \\+b 

 Actual output: 
 b 

 The way I understand 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

Back