Hello --

On Sat, 18 May 2002, Dossy wrote:

> Maybe this is Perl envy, maybe I'm just doing something wrong.
> I'd like to be able to say this:
>
>   x, y = "foo bar" =~ /(foo) (bar)/
>
> and x == "foo" and y == "bar"

This came up as an RCR and was accepted (in Ruby flavor).  So now you have:

  irb(main):003:0> RUBY_VERSION
  "1.7.2"
  irb(main):004:0> all,one,two = "un deux".match(/(un).*(deux)/)
  ["un deux", "un", "deux"]
  irb(main):005:0> all
  "un deux"
  irb(main):006:0> one
  "un"
  irb(main):007:0> two
  "deux"

Note that this is based on the elements of a Ruby MatchData object (not just a
scan of the () captures, as in Perl), so the first element is the whole match,
followed by $1, $2, etc.


David

-- 
David Alan Black
home: dblack / candle.superlink.net
work: blackdav / shu.edu
Web:  http://pirate.shu.edu/~blackdav