Your boss's nosiness is not my problem...but I feel your pain 
(start of string)
(one or zero positive/negative symbols)
(zero ore more numbers in front of an optional decimal point)
(zero ore more numbers)
The second part likely means it must also not start with a decimals and/or spaces
[\+-]?[0-9]+(\.?[0-9]+)?
+0
-0
0
+0.0
+00.00
-000.000
0.0
00.00
$ perl
$_ = '0.00.3';
print "\nnumber!\n" if /[\+-]?[0-9]+(\.?[0-9]+)?/;
^D
number!
my @num = (0, 0.000, +0, +00.00, 00.00, 'one', 'two', 1.2345, '1.two', '.002', '0.002');
for my $num (@num) {
no warnings;
$num = eval $num;
print "'$num' is zero\n" if ($num eq '0');
print "'$num' is a number!\n" if ( ($num + 0) eq $num);
}
'0' is zero
'0' is a number!
'0' is zero
'0' is a number!
'0' is zero
'0' is a number!
'0' is zero
'0' is a number!
'0' is zero
'0' is a number!
'1.2345' is a number!
'0.002' is a number!
'0.002' is a number!
ronelson":1usjg9pl said:Your regex is still too complicated, and wrong (you did not surround it with ^ and $):
That may have a problem, though:It's worth repeating that using the languages built in function for dealing with input is going to be far more readable and maintainable than a regex. In this case, I'm assuming looks_like_number is what should be used and not some implicit language quirks.
sub looks_like_number {
local $_ = shift;
# checks from perlfaq4
return 0 if !defined($_) or ref($_);
return 1 if (/^[+-]?\d+$/); # is a +/- integer
return 1 if (/^([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?$/); # a C float
return 1 if ($] >= 5.008 and /^(Inf(inity)?|NaN)$/i) or ($] >= 5.006001 and /^Inf$/i);
0;
}