From: Divya Badrinath Date: 2007-07-11T07:53:37+09:00 Subject: Re: Help: Efficient regular expression Robert Dober wrote: > On 7/10/07, James Edward Gray II wrote: >> sec, last = cols.values_at(1, -1) > Very interesting James, I seem to be rather extreme and > > sec, last = string.split.values_at(1, -1) > might be a tad to long for one line in your style, however Ruby syntax > just supports this marvelous syntax :) > > sec, last = string.split. > values_at(1, -1) > > Robert cmd = string[/\s(\S+)$/, 1] doesnt fetch me anything:) program=string.split.last what if 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 program=string[/[a-z\/]+$/] the command column mauy start with character. i dont want to limit it in my regexp. it has to be generic. with all your comments, i tried pid = run_process[/\s(\d+)/, 1] cmd = run_process[/:\d+:\d+\s(\S.*)\s$/, 1] is there any other way? -- Posted via http://www.ruby-forum.com/.