哪种方法有一个函数可以在x个字符之后插入内容。
例如,我有这个字符串:
@test = "Something, is wrong"
然后就可以像这样做:
@test.insert(x words or x characters , '<br />')
我需要这个是因为我需要在一个长字符串中插入换行符
<br />
来分隔。哪种方法有一个函数可以在x个字符之后插入内容。
例如,我有这个字符串:
@test = "Something, is wrong"
然后就可以像这样做:
@test.insert(x words or x characters , '<br />')
<br />
来分隔。"abcd".insert(3, 'X') #=> "abcXd"
str[0..2] += "qwerty"
。 - Alexei Averchenko