For example I have some random string:
str = \"26723462345\"
And I want to split it in 2 parts after 6-th char. How to do this correctly?>
The best way IMO is string.scan(/.{6}/)
string.scan(/.{6}/)
irb(main)> str => "abcdefghijklmnopqrstuvwxyz" irb(main)> str.scan(/.{13}/) => ["abcdefghijklm", "nopqrstuvwxyz"]