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:04
Subject:
Re: How do I remove leading zeros?
Message ID:
98b63f13-0d59-907b-854f-ee5a18c16bc9@zoho.com
On 06/13/2018 11:00 AM, Larry Wall wrote:
> I'd probably just write something like:
> 
>      s:g { « <( 0+ )> \d+ » } = '';
> 
> The first <( and the last » are not strictly necessary, but add clarity, or
> at least balance.  But in golf mode you could get away with something like:
> 
>      sg/«0+)>\d//;
> 
> Larry
> 


Awesome!  Thank you!

$ p6 'my $x = "01.0.103.06.10"; $x ~~ s:g/«0+)>\d//; say "$x"'
1.0.103.6.10

What did you just do?

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