From: Vivek Date: 2008-07-13T15:16:19+09:00 Subject: Re: regular expressions help Hi David and others, > On the (usually misappropriated, but hopefully not here) Occam's Razor > principle[1], I would refrain from positing that there's actually > supposed to be a comma between the second "hello" and "world", or that > the quotation marks that were removed to illustrate the results are > actually supposed to be reinstated as literals. We can wait for a > ruling from Vivek, though; he's now got just about every permutation > to choose from :-) (Including shellwords, thanks to Harry, and that of > course is the best. Or at least, if Occam is right, then Harry is > right :-) Thanks for the replies..Indeed I don't want the quotes to be a part of the string This one suggested above by works for me irb(main):028:0> s => "hi there \"hello world\" namaste \"yo man\" \"gutten morgen\" ola \"what's up\" world" irb(main):029:0> s.scan(/"([^"]+)"|(\w+)/).flatten.compact => ["hi", "there", "hello world", "namaste", "yo man", "gutten morgen", "ola", "what's up", "world"] I presume that should capture pretty much any kind of combination.. and I don't have the case where there are nested " so that looks good. (unless someone can think of a case that breaks ) thanks so much..I had hit a dead end trying to do this!! Vivek Krishna