# Extract all numbers and whitespace including punctuation frequently significant to numbers my $numbers = join ' ', $str =~ /([\d .-+]+)/g; # Less whitespace $numbers =~ s/(\s)\1+/$1/g;