Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何将子字符串从某个字符替换为另一个字符串?
first = 4 last = 11 replacement = '...' 'show me the money'.replace_part(first, last, replacement) # => 'show...money'
str = 'show me the money' first = 4 last = 11 replacement = '...' str[first..last] = replacement str #=> 'show...money'