[ruby-core:94238] [Ruby master Bug#16091] gsub
From:
thiaguerd@...
Date:
2019-08-10 00:04:12 UTC
List:
ruby-core #94238
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(/\<tag>[\s\S]*?\<\/tag\>/)
final: my text and my source: xml.scan(/###lt;tag>[\s\S]*?###lt;\/tag###gt;/)
=> nil
>>
```
should not be: "my text and my source: xml.scan(/\<tag>[\s\S]*?\<\/tag\>/)" ??
----------------------------------------
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>