http://www.perlmonks.org?node_id=1005769


in reply to Take digits from a string

Here's the simple solution you asked for:
$string =~ s/[^\d]//g;
But as several people have already mentioned, you really should read the regex docs -- perlretut, perlre, etc. Knowing all about regular expressions will greatly help you process text with Perl.