[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [bug-gawk] Why the length(seps) is one more than the return value of
From: |
Aharon Robbins |
Subject: |
Re: [bug-gawk] Why the length(seps) is one more than the return value of patsplit()? |
Date: |
Tue, 10 Mar 2015 06:25:51 +0200 |
User-agent: |
Heirloom mailx 12.5 6/20/10 |
Hi.
Thanks for the query.
This is working as designed, and as documented. Leading separator characters
are stored in seps[0]. In this case, that element has a null value, but
given the right kind of data, such as "QaAbBcC", it would not be null.
HTH,
Arnold
> Date: Sun, 8 Mar 2015 00:26:47 -0600
> From: Peng Yu <address@hidden>
> To: address@hidden
> Subject: [bug-gawk] Why the length(seps) is one more than the return value
> of patsplit()?
> Hi,
>
> The following code shows that the length(seps) is one more than the
> return value of patsplit(). I thought that seps should have the same
> as the number of elements in "a". Why it is not the case? Could
> anybody help me understand this? Thanks.
>
> ~$ awk 'BEGIN { print patsplit("aAbBcC", a, /[a-z]/, seps); print seps[1],
> seps[2], seps[3], length(seps); }'
> 3
> A B C 4
> --
> Regards,
> Peng