octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: strsplit needs an update


From: Ben Abbott
Subject: Re: strsplit needs an update
Date: Fri, 29 Mar 2013 08:25:10 -0400

On Mar 27, 2013, at 9:16 PM, Ben Abbott wrote:

> On Mar 27, 2013, at 2:19 PM, Jordi Gutiérrez Hermoso wrote:
> 
>> On 27 March 2013 14:07, Ben Abbott <address@hidden> wrote:
>> 
>>> On Mar 27, 2013, at 12:50 PM, Jordi Gutiérrez Hermoso wrote:
>>> 
>>>> So this is why it's always an annoyance to try to implement something
>>>> before Matlab... We've had strsplit since 2009 in Octave, and in 2013,
>>>> TMW finally implements it themselves, with a differing calling form
>>>> than ours:
>>>> 
>>>>  http://www.mathworks.com/help/matlab/ref/strsplit.html
>>>> 
>>>> Anyone feel like chasing after this?
>>> 
>>> Looks like a wrapper around regexp.
>>> 
>>>       [c, matches] = strsplit (str, delimiter, name,  value)
>>> 
>>>       [c, matches] = regexp (str, delimiter, 'split', name, value);
>>> 
>>> Any info on what "name", "value" pairs are supported?
>> 
>> They list two options further down, "CollapsibleDelimiters" and
>> "DelimiterType". Looks like TMW is finally deciding to uniformise
>> passing options to all functions with this ersatz named parameter
>> method. I wonder if this means they'll kill optimset and odeset.
>> 
>> - Jordi G. H.
> 
> From reading the on-line docs, I think the examples below are proper 
> behavior.  Do you agree?
> 
> strsplit ("road to^hell", " ^", "delimitertype", "simple")
> ans = 
> {
>  [1,1] = road
>  [1,2] = to
>  [1,3] = hell
> }

Matlab R2013a works differently.

strsplit ('road to^hell', ' ^', 'delimitertype', 'simple')

ans = 

    'road to^hell'

strsplit ('road to^hell', {' ', '^'}, 'delimitertype', 'simple')

ans = 

    'road'    'to'    'hell'

> strsplit ("road to hell", " ^", "delimitertype", "regularexperession")
> ans = 
> {
>  [1,1] = road to hell
> }
> strsplit ("road to hell", "[ ^]", "delimitertype", "regularexperession")
> ans = 
> {
>  [1,1] = road
>  [1,2] = to
>  [1,3] = hell
> }

Matlab's behavior is the the same as above for regular expressions.

Ben






reply via email to

[Prev in Thread] Current Thread [Next in Thread]