From: Hugh Sasse Date: 2006-11-21T05:37:11+09:00 Subject: Re: Why is slice ignoring my fields at the end of the string? On Tue, 21 Nov 2006, Duane Morin wrote: > I'm not sure if this is a bug with the slice method, or if I'm just > misunderstanding the logic behind it. If I have a string "1,2,3" that I > slice into an array, I get 3 values. OK, but using what code? ----------------------------------------------------------- String#slice [...] str.slice(fixnum) => fixnum or nil str.slice(fixnum, fixnum) => new_str or nil str.slice(range) => new_str or nil str.slice(regexp) => new_str or nil str.slice(regexp, fixnum) => new_str or nil str.slice(other_str) => new_str or nil ------------------------------------------------------------------------ [...] If a +Regexp+ is supplied, the matching portion of _str_ is returned. If a numeric parameter follows the regular expression, that component of the +MatchData+ is returned instead. If a +String+ is given, that string is returned if it occurs in _str_. In both cases, +nil+ is returned if there is no match. I think you must be using /\d+/ or something. Maybe what you want is split(/,/) ? [...] > > Anybody know if this is the intended behavior, and if so, why? I'd You will need to show us the code. > D > Hugh