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


```ruby
include ERB::Util
def r
  puts "Enter original"
  a = gets.chomp
  puts "Enter a pattern to replace"
  b = gets.chomp
  puts "Enter a replacement"
  c = gets.chomp
  puts "a: #{a}"
  puts "b: #{b}"
  puts "c: #{c}"
  c = html_escape c 
  puts "c escaped: #{c}"
  puts "final: #{a.gsub(b,c)}"
end
```

running 

```
>> r
Enter original
my text and my source: ###
Enter a pattern to replace
###
Enter a replacement
xml.scan(/\<tag>[\s\S]*?\<\/tag\>/)
a: my text and my source: ###
b: ###
c: xml.scan(/\<tag>[\s\S]*?\<\/tag\>/)
c escaped: xml.scan(/\&lt;tag&gt;[\s\S]*?\&lt;\/tag\&gt;/)
final: my text and my source: xml.scan(/###lt;tag&gt;[\s\S]*?###lt;\/tag###gt;/)
=> nil
>> 
```

should not be: "my text and my source: xml.scan(/\&lt;tag&gt;[\s\S]*?\&lt;\/tag\&gt;/)" ??

----------------------------------------
Bug #16091: gsub
https://bugs.ruby-lang.org/issues/16091#change-80544

* Author: thiaguerd (thiago feitosa)
* Status: Rejected
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: 2.6.2p47 (2019-03-13 revision 67232) [x86_64-linux]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
```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>