From: "Hal E. Fulton" Date: 2001-10-17T05:53:00+09:00 Subject: [ruby-talk:22641] Re: extracting from delimited text files ----- Original Message ----- From: Sean Middleditch To: ruby-talk ML Sent: Sunday, October 14, 2001 8:55 PM Subject: [ruby-talk:22543] Re: extracting from delimited text files > > > > def csv_split(str) > > > > str.scan(/(?:\A|,)\s*"((?:\\"|[^"])*)"|(?:\A|,)([^",]*|[^",][^,]*)(?=,|\z)/) .flatten!.compact! > > > > end > > > > > > > > > > Jeez, Iit would take me hours to come up with that. If employers took > > > regexp's on resumes, you could get a hell of a job with that. ~,^ > > > > Hehe thanks. It's probably more structured than it looks. For > > instance you could get rid of the \A's by prepending a leading > > comma to the string being processed, prior to feeding it to the > > regexp. It's really just matching: > > > > Dude, I look at that regexp and my eyes stop seeing color, I start > seeing dark spots, and little attack sheep start fighting in front of my > face. ^,^ I can't even *begin* to parse that stuff. :) That reminds me of an idea I had awhile back for a "sub-language" for regular expressions... I think it might make a neat Ruby library. If any regex guru is interested, I'll share my notes on the subject... Hal