my @nums = $x =~ /\d+/g; #### $ perl -le'$x = "a1aa11 b2bb22bbb222 c3cc33"; print for ( $x =~ /\s(\S+)\s/ )[ 0 ] =~ /\d+/g' 2 22 222