0
是否有一種簡單的方法來覆蓋字符串,如下所示,或類似的東西?覆蓋部分字符串
s = "123456"
r1 = "abc"
s.loverwrite(r1) # => "abc456"
s.coverwrite(r1) # => "12abc6" (or "1abc56")
s.roverwrite(r1) # => "123abc"
r2 = "abcdefghi"
s.loverwrite(r2) # => "abcdef"
s.coverwrite(r2) # => "bcdefg" (or "cdefgh")
s.roverwrite(r2) # => "defghi"