in reply to classifying data
I haven't tested this, but it should cover all the basic cases without scientific, but assumes commas are thousands-separators and the decimal point is the fraction separator. You might want to be lenient about leading and trailing spaces, or dollar-before-sign ($-34.00) cases.$value = undef; $value = (0 + "$1$3") if $thing =~ m/ ^ (\-|\+)? # optional sign: $1 (\$)? # optional dollar sign: $2 ( \d+ # at least one digit (,\d\d\d)* # zero or more comma groups (\.\d*)? # optional fractional part | (\.\d+) # only a fractional part ) # the whole mantissa: $3 $ /x; print "numeric! value = $value\n" if defined $value;
--
[ e d @ h a l l e y . c c ]
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: classifying data
by rir (Vicar) on Jan 19, 2004 at 20:21 UTC | |
by paulbort (Hermit) on Jan 19, 2004 at 23:43 UTC | |
by halley (Prior) on Jan 20, 2004 at 03:42 UTC |