Merge pull request #3497 from ksss/subreplace

\1 sequences as empty strings
This commit is contained in:
Yukihiro "Matz" Matsumoto
2017-03-11 10:19:59 +09:00
committed by GitHub
2 changed files with 3 additions and 0 deletions
+2
View File
@@ -34,6 +34,8 @@ class String
m
when "'"
post
when "1", "2", "3", "4", "5", "6", "7", "8", "9"
""
else
self[j, 2]
end
+1
View File
@@ -365,6 +365,7 @@ assert('String#gsub', '15.2.10.5.18') do
assert_equal('$$a$$', '##a##'.gsub('##'){|w| '$$' }, 'mruby/mruby#847 another case with block')
assert_equal('A', 'a'.gsub('a', 'A'))
assert_equal('A', 'a'.gsub('a'){|w| w.capitalize })
assert_equal("<a><><>", 'a'.gsub('a', '<\0><\1><\2>'))
end
assert('String#gsub with backslash') do