in reply to regexp match repetition breaks in Perl

So you want to extract all 3 digit numbers near the string "APCs?"?
my %apc; while ($text =~ m{APC[s]? \s ((\s|\d{3}|,|and)+)}xmsg) { my $extract = $1; while ($extract =~ m{(\d{3})}xmsg) { $apc{$1} = 1; } } for my $apc (sort {$a <=> $b} keys %apc) { print "$apc\n"; }