This doesn't name the groups, but a closure does parameterise the match:
("John 19" =~ /(\w+) (\d+)/).each {match, name, age ->
println match
println name
println age
}
which outputs:
John 19
John
19
This is a useful reference: http://naleid.com/blog/2008/05/19/dont-fear-the-regexp/