[ruby-core:94239] [Ruby master Bug#16091] gsub
From:
thiaguerd@...
Date:
2019-08-10 00:24:16 UTC
List:
ruby-core #94239
Issue #16091 has been updated by thiaguerd (thiago feitosa).
#### on Python 3.7.1
```python
import html
def r():
a = input('Enter original:')
b = input('Enter a pattern to replace:')
c = input('Enter a replacement:')
print(f"a: {a}")
print(f"b: {b}")
print(f"c: {c}")
c = html.escape(c)
print(f"c escaped: {c}")
print(f"final: {a.replace(b,c)}")
```
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(/\<tag>[\s\S]*?\<\/tag\>/)
>>>
# here works ...
```
----------------------------------------
Bug #16091: gsub
https://bugs.ruby-lang.org/issues/16091#change-80546
* Author: thiaguerd (thiago feitosa)
* Status: Open
* 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>