As a sidenote...
On 02 Apr 2003 00:09:18 PST, Nicholas G. Thornton wrote:
>So I'm trying to set up a subroutine to test input types to make sure they're
>the right sort (numeric, etc) I figure regex is the way to go, but it doesn't
>seem to work.
> } elsif ($test_type eq 'decimal' and not $input =~ m/^(\d|\.)*$/) {
> # doesn't test for multiple decimals
Perhaps you could look into the module Regexp::Common, on CPAN,
specificall the patterns $RE{num}{real} and $RE{num}{int}.
Otherwise, either lookahead or alternatives are the way to go, to check
that you have at least one digit and at mosty one digit. For example:
/^(?=.*\d)(\d*\.?\d*)$/
--
Bart.