From: dblack@... Date: 2003-01-12T10:13:35+09:00 Subject: Re: a smart way... Hi -- On Sun, 12 Jan 2003, daniel wrote: > hello, > > I'm new and I'm searching for an smart way to extract > the string 'daniel' from this line > -- > > -- > > I can find this line via: line =~ // > But how to extrace this sting? You can generate a MatchData object, and then address that object with numerical indices. Index 0 will be the whole match; index 1 will be the first () submatch, etc. str = '' m = //.match(str) puts "Whole match is: #{m[0]}" puts "First submatch is: #{m[1]}" (You can also use the special variable $1 to get at the first submatch.) David -- David Alan Black home: dblack@candle.superlink.net work: blackdav@shu.edu Web: http://pirate.shu.edu/~blackdav