how to break a "comma separated string" that contains "comma separated substrings"

20 views
Skip to first unread message

Paulo H.

unread,
Apr 3, 2014, 7:53:29 PM4/3/14
to rubyonra...@googlegroups.com
Hi,

I a comma separated string that contains "comma separated substrings"
like this:

str= ' "hello ,there" ,how,are ,you, "I am , fine" '

every substring that contains comma is in a " ".

I am trying to split str based on, so I should get something like:

"hello ,there"
how
are
you
"I am , fine"

tried many things like "split", ... didn't work.

any idea how to do this.

Thank you

--
Posted via http://www.ruby-forum.com/.

mike2r

unread,
Apr 4, 2014, 7:13:10 AM4/4/14
to rubyonra...@googlegroups.com
Use the Ruby CSV class to parse it.
Reply all
Reply to author
Forward
0 new messages