develooper Front page | perl.perl6.language | Postings from May 2005

Re: split /(..)*/, 1234567890

Thread Previous | Thread Next
From:
David Storrs
Date:
May 12, 2005 09:31
Subject:
Re: split /(..)*/, 1234567890
Message ID:
A54238AB-3D35-46DB-BD4E-B8192C568EEE@dstorrs.com
On May 12, 2005, at 11:59 AM, Autrijus Tang wrote:
> On Thu, May 12, 2005 at 04:53:06PM +0200, "TSa (Thomas Sandla´┐Ż)"  
> wrote:
>> Autrijus Tang wrote:
>>
>>>    pugs> split /(..)*/, 1234567890
>>>    ('', '12', '34', '56', '78', '90')
>>>
>>> Is this sane?
>>
>> Why the empty string match at the start?
>
> I don't know, I didn't invent that! :-)
>
>     $ perl -le 'print join ",", split /(..)/, 123'
>     ,12,3

This makes sense when I think about what split is doing, but it is  
surprising at first glance.  Perhaps this should be included as an  
example in the docs?

--Dks
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