From: Lloyd Linklater Date: 2007-06-13T04:59:38+09:00 Subject: Re: Getting the last N bytes of a string: > p 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.r_slice(0..9) What about this: def last_bytes(s, number_of_bytes) if s.size > number_of_bytes then return s.slice(s.size - number_of_bytes..s.size) end return s end p last_bytes('ABCDEFGHIJKLMNOPQRSTUVWXYZ', 10) p last_bytes('WXYZ', 10) this is the result: "QRSTUVWXYZ" "WXYZ" -- Posted via http://www.ruby-forum.com/.