On Sat, Mar 31, 2012 at 8:31 PM, Jan E. <lists / ruby-forum.com> wrote:
> Hi,
>
> What makes you think that only the last two pairs are matched? This is
> impossible, because you're using the \A and \Z anchors. Either the whole
> string matches or it doesn't match at all.
>
> The regex is actually correct and it does match the example string.

The confusion is that only two capturing groups are returned
(while the first part between brackets matches many times).

1.9.3p125 :001 > s = "11,1,aa,a,1b,3b,55,b6"
 => "11,1,aa,a,1b,3b,55,b6"
1.9.3p125 :002 > s.match(/\A([0-9a-fA-F]{1,2},{1})*([0-9a-fA-F]{1,2}){1}\Z/)
 => #<MatchData "11,1,aa,a,1b,3b,55,b6" 1:"55," 2:"b6">
1.9.3p125 :003 > s.match(/\A([0-9a-fA-F]{1,2},)*([0-9a-fA-F]{1,2})\Z/)
 => #<MatchData "11,1,aa,a,1b,3b,55,b6" 1:"55," 2:"b6">

And as mentioned by gabe, maybe scan is what the  OP was after;

1.9.3p125 :004 > s.scan(/[0-9a-f]{1,2}/i).inspect
 => "[\"11\", \"1\", \"aa\", \"a\", \"1b\", \"3b\", \"55\", \"b6\"]"

1.9.3p125 :005 > s.scan(/([0-9a-f]{1,2}),/i).inspect # more selective
on the comma
 => "[[\"11\"], [\"1\"], [\"aa\"], [\"a\"], [\"1b\"], [\"3b\"], [\"55\"]]"

HTH,

Peter