Which method has a function to insert something after x characters.
Example, I have this string:
@test = "Something, is wrong"
And then it would be possible to do something like:
@test.insert(x words or x characters , '<br />')
I need this because I need to insert a line break <br />
in a long string that I need to break up.
You should start by looking at the String class in the Ruby docs.. http://www.ruby-doc.org/core-1.9.3/String.html
Take a stab at what you think the method you're looking for might be called... in your case insert and see what it says..
"abcd".insert(3, 'X') #=> "abcXd"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With