my $body_text="there are 5 minutes left in the program"; if ($body_text=~m/(\d{1,2})(?=\smins|\sminutes)/g) { print "1st try: " . $1 . "\n"; } if ($body_text=~m/(\d{1,2})(?=\smins|\sminutes)/g) { print "2nd try: " . $1 . "\n"; }