Issue #16091 has been updated by thiaguerd (thiago feitosa).

Backport deleted (2.5: UNKNOWN, 2.6: UNKNOWN)
ruby -v deleted (2.6.2p47 (2019-03-13 revision 67232) [x86_64-linux])
Tracker changed from Bug to Misc

alanwu (Alan Wu) wrote:
> `gsub(pattern, replacement)` always interprets `replacement` as a regex replacement directive.
> You can use the block form to substitute verbatim:
> ```ruby
> a = "test ?"
> b = "?"
> c = "\\&"
> a.gsub(b) { c } #=> "test \\&"
> ```

Nice, tank you.

----------------------------------------
Misc #16091: gsub
https://bugs.ruby-lang.org/issues/16091#change-80576

* Author: thiaguerd (thiago feitosa)
* Status: Open
* Priority: Normal
* Assignee: 
----------------------------------------
```ruby
a = "test ?"
b = "?"
c = "\\&"
a.gsub(b,c)
```



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>