From: Sean Middleditch Date: 2001-10-15T08:21:31+09:00 Subject: [ruby-talk:22535] Re: extracting from delimited text files On Sun, 2001-10-14 at 19:04, Sean Russell wrote: > Sean Middleditch wrote: > > > the scan method will automatically handle the quotation marks? Becasue > > the regular expression wouldn't understand that the comma in "a,b" is > > any different than the other commas... > > > > Sorry if you already explained that, but I wasn't following the thread, > > and I just deleted my mailbox a couple minutes ago (cleaning out the > > cruft... I wish mailers had a function to only delete message over a > > certain age... ah well). > > Doh! No, you're right. I had it right the first time. I should have > learned by now never to question my mself. Foolish me for thinking I could > have been wrong! The proper regexp should be > > /".*?"|[^,]*/ > I still think there may be problems... the quotes might have to be escaped. Also, what about something like abc,def,\"abc,"123,456"\,xxy The escapes won't work. I once had a regexp that (in almost all cases) properly handled this, but I don't recall what it was. Unfortunately, I'm not talented enough at regexps to figure it out again without another hour of work. ^,^ I don't know if handling the \ escapes is important though for this situation (I had some text files at work that did need it, though... was a real pain). > BTW, are you a member of IBOS? > Off the top of my head, I don't even know what IBOS is, so I'm going to assume that I'm not. Is that a group I should be familar with? > --- SER > > > -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- > http://www.newsfeeds.com - The #1 Newsgroup Service in the World! > Check out our new Unlimited Server. No Download or Time Limits! > -----== Over 80,000 Newsgroups - 19 Different Servers! ==----- Sean Etc.