Apr 21, 2009, 2:07 AM
Post #4 of 8
Re: [ichi] Regular expressions needed..
[In reply to]
Thank you so much for reply. I made a small modifiction by including || operator in the middle, but it is not working. What is my mistake. My intention here is , i want to check for 3 digits or 2 digits before the dot(.) operator and i want to print the number
12.89383787 ---> 12.89 is expected output.
128.9383787 ---> 128.93 is expected output. like this...
$num = 12.89383787;
$num = $num =~ /(\d\d\d\.\d\d)/ || /(\d\d\.\d\d)/ ? $1 : substr $num,0,2;
In a float number, i want to take all the digits left side of the dot (.) and 2 digits after the dot (.)