in reply to How to strip non-numeric values from string?
my @array = (" 321abc ", "100%", "20 lbs."); no warnings "numeric"; print(0+$_,"\n") for @array;
If you have leading chaff, you can run it through a substitution to strip that first:
my @array = (" 321abc ", "100%", "20 lbs.", "words20", "**39.99.99** +"); no warnings "numeric"; for (@array) { s/^[^0-9.-]+//; print(0+$_,"\n"); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to strip non-numeric values from string?
by murugaperumal (Sexton) on Mar 20, 2010 at 04:20 UTC |