From: Phrogz Date: 2009-10-31T07:30:05+09:00 Subject: Re: How do you get the tail end of a string? On Oct 30, 5:11 am, Bertram Scharpf wrote: > Am Freitag, 30. Okt 2009, 13:25:05 +0900 schrieb Michael W. Ryder: > > Michael W. Ryder wrote: > >> Just Another Victim of the Ambient Morality wrote: > >>>     I'm actually hoping this is an embarrassing question but how do you > >>> get the tail end of a string?  All I've figured out is this: > > >>> index = 4 > >>> string[index, string.size - index] > > >>>     ...but surely there's a better way. > > >> You mean like string[-1]? > > > I'm sorry, I missed the part about the index number of characters.  Try > > string[-index, index]. > > That's really ugly. You shouldn't have to mention `index' twice. > I would even support a language extension to solve this problem. No need for any extensions. irb(main):001:0> "123456"[-4..-1] => "3456"