in reply to How to remove non-numbers from string
UPDATE: Sound enough code (and can be adapted (below) to OP's needs), but NOT a complete answer to OP's question, which I mis-read.
Use the inverse of your regex, namely:
$string=~ s/\d//g;
like this without having to add additional tests to deal with strings which have no numbers:
C:\>perl -E "my $string=('data12.csv');$string=~ s/\d//g;say $string; data.csv C:\>perl -E "my $string=('data.csv');$string=~ s/\d//g;say $string;" data.csv
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to remove non-numbers from string
by ww (Archbishop) on Jun 22, 2015 at 13:48 UTC |