Autrijus Tang wrote:
I don't know, I didn't invent that! :-)

    $ perl -le 'print join ",", split /(..)/, 123'
    ,12,3

Hmm,

perl -le 'print join ",", split /(..)/, 112233445566'
,11,,22,,33,,44,,55,,66

For longer strings it makes every other match an empt string.
With the "Positions between chars" interpretation the above
string is with '.' indication position:

.1.1.2.2.3.3.4.4.5.5.6.6.
0 1 2 3 4 5 6 7 8 9 1 1 1
                    0 1 2

There are two matches each at 0, 2, 4, 6, 8 and 10.
The empty match at the end seams to be skipped because
position 12 is after the string? And for odd numbers of
chars the before last position doesn't produce an empty
match:
perl -le 'print join ",", split /(..)/, 11223'
,11,,22,3

Am I the only one who finds that inconsistent?
--
TSa (Thomas Sandla▀)



Reply via email to