my $body_text="there are 5 minutes left in the program"; if ($body_text=~m/\d{1,2}(?=\s(mins|minutes))/g) { print $1; }