doubledecker has asked for the wisdom of the Perl Monks concerning the following question:
Hi Monks
I am trying the following regex to match the numbers after the decimal. If my input is -1.500, output is coming only as 5. Infact, it should be 500. Please help to correct my regex.
my $price = -1.500; if ( $price =~ m/^-\d+\.(\d*)$/g ) { print "matched $1 \n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: regex to match numbers after decimal
by NetWallah (Canon) on Jan 15, 2014 at 05:35 UTC | |
|
Re: regex to match numbers after decimal
by Kenosis (Priest) on Jan 15, 2014 at 05:40 UTC |