blnukem
asked on
Regex fix
Hi all
I need this fixed it works as long as $PintedDiscount doesn't end with "0" example 10, 20, 30, 40, 50
DONT WORK: $PintedDiscount = 0.20;
WORKS: $PintedDiscount = 0.25;
$PintedDiscount =~ s/^[0\.]+//;
print "$PintedDiscount%";
I need this fixed it works as long as $PintedDiscount doesn't end with "0" example 10, 20, 30, 40, 50
DONT WORK: $PintedDiscount = 0.20;
WORKS: $PintedDiscount = 0.25;
$PintedDiscount =~ s/^[0\.]+//;
print "$PintedDiscount%";
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
$PintedDiscount =~ s/^[0\.]+(.*[1-9])$/$1/;
ASKER
Thanks Tintin
Maybe you should just multiply $PintedDiscount *100