From: Phrogz Date: 2007-08-21T06:45:00+09:00 Subject: Re: Regexp: named captures On Aug 20, 3:32 pm, William James wrote: > On Aug 20, 2:44 pm, Ari Brown wrote: > > How do named captures in Ruby work? This is what I've tried: > A work-around: > > md = "foo bar".match( /(\w+) (\w+)/ ) > ==># > name, surname = md.captures > ==>["foo", "bar"] > name > ==>"foo" > surname > ==>"bar" Or my favorite (courtesy of Ara): _, name, surname = /(\w+) (\w+)/.match("foo bar").to_a