From: Robert Keller Date: 2007-10-23T22:23:14+09:00 Subject: Re: format string for array question --0-801464969-1193145395=:1291 Content-Type: text/plain; charset=us-ascii Cool, Thank you for the help! ------------------------------ Robert Keller rlkeller@yahoo.com ----- Original Message ---- From: Gennady Bystritsky To: ruby-talk ML Sent: Monday, October 22, 2007 5:05:59 PM Subject: Re: format string for array question Robert Keller wrote: > I have a great deal of data that looks like the line below > > "db file parallel write 8816 391 25.49" > > > The code to bring this into an array had a problem due to the spaces > in the test string "db file parallel write" I'd be happy to turn "db > file parallel write" into db_file_parallel_write (with underscores) > first then just split the string, but all of the regex I've tried so > far has had negative effects on the rest of the string with the > numbers. > > > > ------------------------------ > Robert > rlkeller@yahoo.com [rh-30-x86.irvspxl08:2182]gbystrit> irb irb(main):001:0> s = "db file parallel write 8816 391 25.49" => "db file parallel write 8816 391 25.49" irb(main):002:0> s.split(%r{(?:\s+)([\d.]+)}).reject {|s| s.empty?} => ["db file parallel write", "8816", "391", "25.49"] irb(main):003:0> =Gennady. --0-801464969-1193145395=:1291--