From: Brian Candler Date: 2010-09-18T04:20:49+09:00 Subject: Re: ruby regexpresion Ruwan Budha wrote: > (21:15:32:873) SMART>> Starting Process '/abs/nc/qwcy/xyz'. pid 11560 > > > I want to parse the following few things from the above string > > (21:15:32:873) > xyz > pid 11560 > > and output as below, > > (21:15:32:873), xyz, pid 11560 > > > I am stuck and I would appreciate if someone could give me some help. I > am newbie to ruby....thanks http://www.ruby-doc.org/docs/ProgrammingRuby/ is a good start. Read the bits about regular expressions. You can match the line with a regular expression, and use capture groups (in parentheses) to pick out the bits you want. >> str = "hello/to/you" => "hello/to/you" >> str =~ %r{(.*)/(.*)} => 0 >> $1 => "hello/to" >> $2 => "you" -- Posted via http://www.ruby-forum.com/.