develooper Front page | perl.perl6.users | Postings from June 2018

Re: How do I remove leading zeros?

Thread Previous | Thread Next
From:
ToddAndMargo
Date:
June 13, 2018 18:01
Subject:
Re: How do I remove leading zeros?
Message ID:
290c354b-decd-4bb1-009c-7e924681e7cf@zoho.com
On 06/12/2018 10:22 PM, Norman Gaywood wrote:
> On Wed, 13 Jun 2018 at 14:57, ToddAndMargo <ToddAndMargo@zoho.com 
> <mailto:ToddAndMargo@zoho.com>> wrote:
> 
>     I am trying to turn
> 
>           01.02.03
> 
>     into
> 
>           1.2.3
> 
>     What am I doing wrong, this time?
> 
>     $ p6 'my $x="01.02.03"; $x ~~ s:global/"0"(\d)/ $0 /; say "$x"'
>        1 . 2 . 3
> 
> 
> The second part of the s/// operator is a string (spaces count), not a 
> regex (spaces ignored).
> 
>  > my $x="01.02.03"; $x ~~ s:global/"0"(\d)/$0/; say "$x"
> 1.2.3


Thank you!

$ p6 'my $x = "01.0.3.06.10"; $x ~~ s:global/"0"(\d)/$0/; say "$x"'
1.0.3.6.10

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About