From: Dany Wu Date: 2007-10-30T12:22:02+09:00 Subject: Re: How to trim a string 7stud -- wrote: > Dany Wu wrote: >> ...I'm looking for a way to return an x number of characters >> from a string, eg. 5 characters starting from position 10 in the string, >> the last 10 chars, the first 15 chars, etc. >> >> Is there a String method that does this? I can't seem to find any but I >> may have missed something glaringly obvious. Any help would be greatly >> appreciated. >> > ... Some excellent examples > > #the first 15 chars: > > sub_str = str[0...15] #notice the 3 dots v. 2 dots > puts sub_str + "<----" > > --output:-- > In the absence <---- Thank you very much for the detailed explanation. Much appreciated. Cheers, Dany. -- Posted via http://www.ruby-forum.com/.