From: "Eregon (Benoit Daloze)" Date: 2013-03-21T21:57:42+09:00 Subject: [ruby-core:53603] [ruby-trunk - Bug #8136] gsub strange behavior when substituting "\\'" Issue #8136 has been updated by Eregon (Benoit Daloze). Seems like \' is interpreted as $' ($POSTMATCH) which is in this case 'oo'. ---------------------------------------- Bug #8136: gsub strange behavior when substituting "\\'" https://bugs.ruby-lang.org/issues/8136#change-37792 Author: alexeymuranov (Alexey Muranov) Status: Open Priority: Normal Assignee: Category: Target version: ruby -v: 2.0.0 =begin s = "\\'" # => "\\'" print s # \' "foo".gsub("f", s) # => "oooo" Can anybody please explain to me why it works like this? Is this a bug? =end -- http://bugs.ruby-lang.org/