• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 162
  • Last Modified:

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%";

0
blnukem
Asked:
blnukem
1 Solution
 
Adam314Commented:
What are you trying to do?

Maybe you should just multiply $PintedDiscount *100
0
 
TintinCommented:
As Adam is saying:

$PintedDiscount = 0.20;
print $PintedDiscount * 100 . "%\n";
0
 
rugdogCommented:
$PintedDiscount =~ s/^[0\.]+(.*[1-9])$/$1/;
0
 
blnukemAuthor Commented:
Thanks Tintin
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now