[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: strsplit
From: |
Mike Miller |
Subject: |
Re: strsplit |
Date: |
Thu, 5 Jun 2014 20:01:31 -0400 |
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
- strsplit, Juan Pablo Carbajal, 2014/06/05
- Re: strsplit, Ben Abbott, 2014/06/05
- Re: strsplit,
Mike Miller <=