in reply to Re: Regex Dollar Amounts
in thread Regex Dollar Amounts

Hi
Thanks for the help!
I messed up copying my code. Darn.
Here it is again, done correctly.

$Amount =~ /-?(\d+)\.?(\d+)/; $intergerpart = $1; $decimalpart = $2; $lengthdecimal = length($decimalpart); if ($lengthdecimal gt 2 || $Amount =~ /[^0-9]\.?[^0-9]/) { display_output($templatefile,); print <<EOF;

Thanks for the help. I'll give your idea a try.

Replies are listed 'Best First'.
Re: Re: Re: Regex Dollar Amounts
by Additude (Initiate) on Oct 19, 2001 at 15:51 UTC
    Hi Again Eric
    I tried the line
    if($amount =~ m/^-?(\d+)\.(\d\d)$/)
    But this regex is forcing me to put a non digit character in place for it to be true
    If I use $50.00, c50.00, abcd50.00 and so on it will produce a true result and allow the user to pass.
    So here is what I did and it seems to be working
    if ($Amount !~ m/^-?(\d+)\.(\d\d)$/) { display_output($templatefile,);#error page print <<EOF;#good result, move on

    I had to change the =~ to !~ because it didn't like having
     print <<EOF; before the display_output($templatefile,);
    for some reason.
    But it looks like all is well in Dodge City now. Thanks!
    Wes