On Mon, Jun 9, 2008 at 12:46 PM, Justin To <tekmc / hotmail.com> wrote:
> That is great Thomas! Although, I'd like to know how to do it with the
> regular expressions as well.

I'd recommend using Sring#split.  In the simplest case you could just
specify line.split(','); no regular expressions needed.  If you wanted
you could use a regular expression argument to #split in order to skip
whitespace:

  line.split(/\s*,\s*/)

but you could just as easily trim the values after the fact too:

  line.split(',').map{|v| v.strip}


Regular expressions are not the best solution for parsing CSV,
especially once you start dealing with quoted values.

-- 
Avdi

Home: http://avdi.org
Developer Blog: http://avdi.org/devblog/
Twitter: http://twitter.com/avdi
Journal: http://avdi.livejournal.com