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:06
Subject:
Re: How do I remove leading zeros?
Message ID:
15cc4bde-c7dc-d7f2-f1da-682335b8ede0@zoho.com
On 06/13/2018 11:03 AM, ToddAndMargo wrote:
> 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?


Sweet!

    $ p6 'my $x = "01.000.103.006.10"; $x ~~ s:g/«0+)>\d//; say "$x"'
    1.0.103.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