From: James Edward Gray II Date: 2005-12-15T07:22:21+09:00 Subject: Re: regular expressions question On Dec 14, 2005, at 4:03 PM, ako... wrote: > thank you. the question is general. > > if i wanted to parse a list of letters separated by spaces and commas: > > 'a , b,c' =~ /^(?:(\w)\s*,\s*)*(\w)$/ > > i need to get ['a','b'] in group 1 and ['c'] in group 2. yes, i know i > can split, then massage the result some more and get the final result. > is there a way to get to groups' captures after a regex match? like in > microsoft's .net? Perl-style variables: >> "abc" =~ /(.)(.)(.)/ => 0 >> p [$1, $2, $3] ["a", "b", "c"] => nil Or object oriented: >> md = "abc".match(/(.)(.)(.)/) => # >> p [md[1], md[2], md[3]] ["a", "b", "c"] => nil Hope that helps. James Edward Gray II