It is possible to do with one regexp.
local our @matches; $str =~ / (?{ [] }) ^foo (?: \s+ m \s+ (\d+) (?{ [ @{$^R}, $^N ] }) )+ \s+ bar (?{ @matches = @{$^R} }) /x;
Didn't say it was nice.
In reply to Re: Arbitrary number of captures in a regular expression
by ikegami
in thread Arbitrary number of captures in a regular expression
by grinder
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |