Lee5
asked on
Matching only numbers
What is the pattern to match only numbers
ie;
a$ = "Yes" if(b$ contains only numbers);
ie;
a$ = "Yes" if(b$ contains only numbers);
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Actually, that will treat an empty string as a number. If you don't want that, simply replace * with +.
Martin
Martin
Furthermore, what it the number is
7.0e6
There's a FMTYEWTK about this on the perl.com site. I generallly do
sub IsNumber {
local($^W) = 0;
my($a) = shift;
return 0 if !defined($a);
$a = s/^\s+|\s+$//;
return 0 if $a eq '';
return $a == $a + 0;
}
return $a == $a + 0;
7.0e6
There's a FMTYEWTK about this on the perl.com site. I generallly do
sub IsNumber {
local($^W) = 0;
my($a) = shift;
return 0 if !defined($a);
$a = s/^\s+|\s+$//;
return 0 if $a eq '';
return $a == $a + 0;
}
return $a == $a + 0;
>> FMTYEWTK
What would that be in plain english?
Martin
What would that be in plain english?
Martin
ASKER
Also thanks to b2pi and martinag
Far More Than You Ever Wanted To Know
(Like FAQ, but Not so Frequent :))
(Like FAQ, but Not so Frequent :))
Martin