[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Regex fix

Posted on 2007-07-24
4
Medium Priority
?
161 Views
Last Modified: 2010-03-05
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
Comment
Question by:blnukem
4 Comments
 
LVL 39

Expert Comment

by:Adam314
ID: 19560309
What are you trying to do?

Maybe you should just multiply $PintedDiscount *100
0
 
LVL 48

Accepted Solution

by:
Tintin earned 2000 total points
ID: 19560350
As Adam is saying:

$PintedDiscount = 0.20;
print $PintedDiscount * 100 . "%\n";
0
 
LVL 7

Expert Comment

by:rugdog
ID: 19560488
$PintedDiscount =~ s/^[0\.]+(.*[1-9])$/$1/;
0
 

Author Comment

by:blnukem
ID: 19561409
Thanks Tintin
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question