From: "Peña, Botp" Date: 2007-07-11T13:19:04+09:00 Subject: Re: Help: Efficient regular expression On Behalf Of Divya Badrinath: # string = "root 14051 14033 3 08:39 pts/2 00:00:00 /bin/bash -x -s" # it fetches only -s for me. # sec, last = string.split.values_at(1, -1) # doesnt work for the same reason # i need everything after 00.00.00 till the end # i.e., /bin/bash -x -s you can modify the non-regex solutions since they are just plain array manipulations irb(main):003:0> str = "root 14051 14033 3 08:39 pts/2 00:00:00 /bin/bas h -x -s" => "root 14051 14033 3 08:39 pts/2 00:00:00 /bin/bash -x -s" irb(main):006:0> astr = str.split => ["root", "14051", "14033", "3", "08:39", "pts/2", "00:00:00", "/bin/bash", "- x", "-s"] irb(main):007:0> pid = astr[1] => "14051" irb(main):010:0> cmd = astr[7..-1].join " " => "/bin/bash -x -s" or irb(main):024:0> pid,*cmd = astr.values_at(1,7..-1) => ["14051", "/bin/bash", "-x", "-s"] irb(main):025:0> pid => "14051" irb(main):026:0> cmd => ["/bin/bash", "-x", "-s"] irb(main):027:0> cmd = cmd.join " " => "/bin/bash -x -s"