From: Michal Suchanek Date: 2010-02-07T04:47:46+09:00 Subject: Re: match/scan does not return multiple matches On 6 February 2010 19:57, Ralf Mueller wrote: > Michal Suchanek wrote: >> >> Hello >> >> I tried scanning for multiple occurences of a group in a string and >> match/scan would return only one. >> >> >> "ajabcabck".match /^a*j(?:b*(a+)b+c*)+k$/ >> => # >> >> "ajabcabck".scan /^a*j(?:b*(a+)b+c*)+k$/ >> => [["a"]] >> >> >> clearly the a+ group must match twice to match the string from ^ to $ >> but only single match is returned. >> >> It is possible to use split instead but using a single match would be >> much nicer. >> >> Any workaround? >> >> ruby 1.8.7 (2010-01-10 patchlevel 249) [i486-linux] >> >> >> Thanks >> >> Michal >> >> > > Hi > as far as i know, nested groups are not allowed. regular expressions do not > form a language. Actually they are allowed, otherwise I would not get a match at all. Note also that I have manually unnested them in the example. The problem is that repeated matches of the group are not returned. Thanks Michal