Hi -- On Sun, 13 Jul 2008, Vivek wrote: > 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!! Don't forget the shellwords library though -- a very convenient way to do this. David -- Rails training from David A. Black and Ruby Power and Light: Intro to Ruby on Rails July 21-24 Edison, NJ Advancing With Rails August 18-21 Edison, NJ See http://www.rubypal.com for details and updates!