Hi -- On Sun, 19 May 2002, Dossy wrote: > On 2002.05.19, David Alan Black <dblack / candle.superlink.net> wrote: > > > > You want a method called #match that throws away the match? :-) > > For simplicity, yes. $~[0] contains the match, if and when I ever > need it. > > Out of sheer habit, if I wanted the whole match, I would want > to write: > > x, y, z = "foo bar" =~ /((foo) (bar))/ > x # => "foo bar" > y # => "foo" > z # => "bar" Remember that the underlying concept of the "match" is a match between a string and a pattern. The thing you're doing -- embracing the whole match in the widest set of parentheses -- is what pattern matching fundamentally already does. So by adding those parens, you're really just shadowing the functionality that already exists. (In Perl I can't remember whether the match is returned anywhere other than the dreaded $& (?), but in Ruby you can definitely always get easy access to the match.) David -- David Alan Black home: dblack / candle.superlink.net work: blackdav / shu.edu Web: http://pirate.shu.edu/~blackdav