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

Re: How do I remove leading zeros?

Thread Previous | Thread Next
From:
Norman Gaywood
Date:
June 13, 2018 05:22
Subject:
Re: How do I remove leading zeros?
Message ID:
CAHJ-_U7UQcdk=iYDDtwhww1kTtJzCJH9cYq+=oFgfsNB9QD0=A@mail.gmail.com
On Wed, 13 Jun 2018 at 14:57, ToddAndMargo <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

-- 
Norman Gaywood, Computer Systems Officer
School of Science and Technology
University of New England
Armidale NSW 2351, Australia

ngaywood@une.edu.au  http://turing.une.edu.au/~ngaywood
Phone: +61 (0)2 6773 2412  Mobile: +61 (0)4 7862 0062

Please avoid sending me Word or Power Point attachments.
See http://www.gnu.org/philosophy/no-word-attachments.html

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