use warnings; use strict; my $f='chapter 01,02,03,04'; if(my @m=$f=~/,([0-9]{2})/g){ print "@m\n"; #prints 02 03 04 }