From: Akinori MUSHA Date: 2000-10-05T04:38:55+09:00 Subject: [ruby-talk:5290] Re: MatchData methods At Thu, 5 Oct 2000 04:26:40 +0900, Louis A. Mamakos wrote: > So, I was regexp'ing away just now, and noted a MatchData method missing which > would be very useful (at least to me). I was doing something like this: > > re = Regexp.compile("([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])") > match = re.match(someRandomString) > foo = match.slice(1,2).join(':') > > which of course didn't work. I had assumed that since MatchData had > a [] method, it might also support some other array-like functionality. Is > there a way to extract an array of the matched results from a MatchData > object? to_a is your friend: foo = match.to_a.slice(1,2).join(':') -- / /__ __ / ) ) ) ) / Akinori -Aki- MUSHA aka / (_ / ( (__( @ idaemons.org / FreeBSD.org "We're only at home when we're on the run, on the wing, on the fly"