Just for the heck of it, I'd thought I'd throw out the perl5 version...
$oporm = qr{[+-]?};
$digit = qr{\d};
$fixed = qr{ $oporm $digit+ \.? $digit*
| $oporm $digit* \.? $digit+ }x;
$scino = qr{ $fixed [eE] $oporm $digit+ | $fixed | $digit+ }x;
sub is_scino
{
my $num = shift;
if ($num =~ m/^$scino$/)
{
$num = $num + 0; # is this really necessary?
return $num;
}
return undef;
}
sub is_fixed
{
my $num = shift;
if ($num =~ m/^$fixed$/)
{
$num = $num + 0;
return $num;
}
return undef;
}
-- All code is 100% tested and functional unless otherwise noted.