Issue #8136 has been updated by alexeymuranov (Alexey Muranov).


nobu (Nobuyoshi Nakada) wrote:
> =begin
> You need more escapes.
> 
>   "foo".gsub("f", "\\\\'")
> =end

Thank you, i have not read the documentation carefully.  It is still a bit strange to me that a replacement string is not taken literally by default.
----------------------------------------
Bug #8136: gsub strange behavior when substituting "\\'"
https://bugs.ruby-lang.org/issues/8136#change-38081

Author: alexeymuranov (Alexey Muranov)
Status: Closed
Priority: Normal
Assignee: 
Category: doc
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/