如何通过其他字符串将子字符串从某个字符替换为另一个字符?
first = 4
last = 11
replacement = '...'
'show me the money'.replace_part(first, last, replacement)
# => 'show...money'
Run Code Online (Sandbox Code Playgroud)
fre*_*oid 15
str = 'show me the money'
first = 4
last = 11
replacement = '...'
str[first..last] = replacement
str
#=> 'show...money'
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2000 次 |
| 最近记录: |