Hi --

On Thu, 9 Nov 2006, Chris Mueller wrote:

> Hi,
> i am new to ruby and i am wondering how many more ways (and what ways)
> there are to do this:
>
> seperated_words = "hi, you, guys"
> words_array = seperated_words.split(",")
> for i in 0 ... words_array.length
>  words_array[i] = words_array[i].strip
> end

Here's one way:

   separated_words.scan(/[^\s,]+/)

And another:

   require 'csv'
   CSV.parse_line(separated.words.delete(' '))


David

-- 
                   David A. Black | dblack / wobblini.net
Author of "Ruby for Rails"   [1] | Ruby/Rails training & consultancy [3]
DABlog (DAB's Weblog)        [2] | Co-director, Ruby Central, Inc.   [4]
[1] http://www.manning.com/black | [3] http://www.rubypowerandlight.com
[2] http://dablog.rubypal.com    | [4] http://www.rubycentral.org