Is there a function in Perl equivalent to TrimRight. I need to trim the trailing chars '0' from a string.
Can you help me?
Printable View
Is there a function in Perl equivalent to TrimRight. I need to trim the trailing chars '0' from a string.
Can you help me?
might require Perl 5:
$_= "the string000";
s/(.*?)0*$/$1/gi;
print($_);
Thanks !
It was veri helpfull !
But I wolu like to ask you something more.
I have a value, for exemple:
$_ = "1234.0000";
#i execute your code
s/(.*?)0*$/$1/gi;
and the string is "1234."
How can I also remove the trailing "." ?
I would be very gratefull to you if you could help me out ...
$_= "1234.000";
s/(.*?)\.?0*$/$1/gi;
print($_);
You-ve been great !
Thank you !
I gave you 3 grades.