[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: strsplit
From: |
Juan Pablo Carbajal |
Subject: |
Re: strsplit |
Date: |
Fri, 6 Jun 2014 02:04:17 +0200 |
On Fri, Jun 6, 2014 at 2:01 AM, Mike Miller <address@hidden> wrote:
> On Fri, Jun 6, 2014 at 01:05:53 +0200, Juan Pablo Carbajal wrote:
>> Hi,
>>
>> Is the following behavior correct in strsplit?
>>
>> strsplit("/usr/local/share/octave/",filesep())
>> ans =
>> {
>> [1,1] =
>> [1,2] = usr
>> [1,3] = local
>> [1,4] = share
>> [1,5] = octave
>> [1,6] =
>> }
>>
>> strsplit("/usr/local/share/octave/",filesep(),true)
>> ans =
>> {
>> [1,1] =
>> [1,2] = usr
>> [1,3] = local
>> [1,4] = share
>> [1,5] = octave
>> [1,6] =
>> }
>>
>> strsplit("/usr/local/share/octave/",filesep(),false)
>> ans =
>> {
>> [1,1] =
>> [1,2] = usr
>> [1,3] = local
>> [1,4] = share
>> [1,5] = octave
>> [1,6] =
>> }
>>
>>
>> The output puts an empty cell element when the matching delimiter is
>> at the beginning and at the end.
>> This causes geometry ADD_PKG script to fail, so the behavior changed
>> not long ago (I remember some mails about this, ml compatibility?).
>
> I see the same behavior in 3.4.3, 3.6.4, and 3.8.1 for this example.
> See also the ostrsplit function in 3.8 which operates like the old
> strsplit.
>
> Anyway, according to bug #39010 [1], it looks like yes, a string that
> begins and ends with the delimiter should return an empty string from
> both ends.
>
> [1] https://savannah.gnu.org/bugs/?39010
>
> --
> mike
Thank you fro the quick response and the tests.
ok, I guess this is hereditary disease (or can anybody justify this behavior?).
If the behavior is so old I wonder how I wasn't getting the failure before.
Anyways I replaced the use of strsplit with fullfile, hopefully this
is more robust and portable.
- strsplit, Juan Pablo Carbajal, 2014/06/05