Reputation: 14770
How I can replace substring from some character to another by other string?
first = 4
last = 11
replacement = '...'
'show me the money'.replace_part(first, last, replacement)
# => 'show...money'
Upvotes: 7
Views: 3197
Reputation: 14770
str = 'show me the money'
first = 4
last = 11
replacement = '...'
str[first..last] = replacement
str
#=> 'show...money'
Upvotes: 20