Martin A. Hansen wrote:
> hi
>
>
> what do a regex look like that only matches numbers of the format
>
> (the length of the number doesnt matter its the . thats the problem)
>
> 1233.1234
>
> or
>
> 1234
>
i don't know how much you want to go but do you consider the following valid
number:
+23
-12.43
-.34
0.34
-.0
0.43e23
-9.34e+13
+12e-23
0.23e-8
89.87
the following checks all of the above format:
#!/usr/bin/perl -w
use strict;
my $i = '4.34e1';
if($i =~ /^[-+]?\d*(\.\d+|\d*)(e[+-]?\d+)?$/){
print "match\n";
}else{
print "not match\n";
}
__END__
it doesn't include things like these:
8.
-9.
.
+.
4.3e
david
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]