From: Daniel DeLorme Date: 2007-08-12T10:52:57+09:00 Subject: Re: first and last char Stefan Rusterholz wrote: > Ew, that's awfully complex. You create n new objects from which you > throw n-1 away again... > Think of the memory! ;-) > def first; self[0,1]; end; def last; self[-1,1]; end wrong, that's the first and last *bytes*, not characters. def first; self[/\A./m]; end def last; self[/.\z/m]; end >> $KCODE='u' => "u" >> "日本語".first => "日" >> "日本語".last => "語" Daniel