I have a string like 'foo|bar||foobar|' and I want to split it into
separate tokens like: 'foo|bar||foobar|' subStrings: $| -> #('foo' 'bar' '' 'foobar' ''). It is... to INCLUDE empty strings (or nil for that case) for the elements between to consecutive separators. I can't found a method implementing this in Pharo (in Dolphin it works as I expect). Thank you! Esteban A. Maringolo |
In VA, tgey just introduced allSubStrings: for this matter, because subStrings was changed to return only non-empty parts...
Do you find that in Pharo? Joachim "Esteban A. Maringolo" <[hidden email]> schrieb: >I have a string like 'foo|bar||foobar|' and I want to split it into >separate tokens like: > >'foo|bar||foobar|' subStrings: $| -> #('foo' 'bar' '' 'foobar' ''). > >It is... to INCLUDE empty strings (or nil for that case) for the >elements between to consecutive separators. > >I can't found a method implementing this in Pharo (in Dolphin it works >as I expect). > >Thank you! > >Esteban A. Maringolo > > |
No, there is no #allSubStrings: .
However, after your email (and having solved my issue in other way) I just found #findTokens:escapedBy: which does exactly what I need :) 'foo,baz,"3,14",,foobaz' findTokens: $, escapedBy: $". -> an OrderedCollection('foo' 'baz' '3,14' '' 'foobaz') Regards! Esteban A. Maringolo 2013/11/20 Joachim Tuchel <[hidden email]>: > In VA, tgey just introduced allSubStrings: for this matter, because subStrings was changed to return only non-empty parts... > Do you find that in Pharo? > > Joachim > > "Esteban A. Maringolo" <[hidden email]> schrieb: > >>I have a string like 'foo|bar||foobar|' and I want to split it into >>separate tokens like: >> >>'foo|bar||foobar|' subStrings: $| -> #('foo' 'bar' '' 'foobar' ''). >> >>It is... to INCLUDE empty strings (or nil for that case) for the >>elements between to consecutive separators. >> >>I can't found a method implementing this in Pharo (in Dolphin it works >>as I expect). >> >>Thank you! >> >>Esteban A. Maringolo >> >> |
In reply to this post by Esteban A. Maringolo
Am 20.11.2013 um 04:20 schrieb Esteban A. Maringolo <[hidden email]>: > I have a string like 'foo|bar||foobar|' and I want to split it into > separate tokens like: > > 'foo|bar||foobar|' subStrings: $| -> #('foo' 'bar' '' 'foobar' ''). > > It is... to INCLUDE empty strings (or nil for that case) for the > elements between to consecutive separators. > > I can't found a method implementing this in Pharo (in Dolphin it works > as I expect). > $| split: 'foo|bar||foobar|' Norbert |
In reply to this post by Esteban A. Maringolo
Propose allSubStrings: with a couple of tests and a nice comment.
so that we improve the lib. For me findTokens:escapedBy: is Really Bad Name looking from prehistorical ages. Stef On Nov 20, 2013, at 6:57 AM, Esteban A. Maringolo <[hidden email]> wrote: > No, there is no #allSubStrings: . > > However, after your email (and having solved my issue in other way) I > just found #findTokens:escapedBy: which does exactly what I need :) > > 'foo,baz,"3,14",,foobaz' findTokens: $, escapedBy: $". -> an > OrderedCollection('foo' 'baz' '3,14' '' 'foobaz') > > Regards! > Esteban A. Maringolo > > > 2013/11/20 Joachim Tuchel <[hidden email]>: >> In VA, tgey just introduced allSubStrings: for this matter, because subStrings was changed to return only non-empty parts... >> Do you find that in Pharo? >> >> Joachim >> >> "Esteban A. Maringolo" <[hidden email]> schrieb: >> >>> I have a string like 'foo|bar||foobar|' and I want to split it into >>> separate tokens like: >>> >>> 'foo|bar||foobar|' subStrings: $| -> #('foo' 'bar' '' 'foobar' ''). >>> >>> It is... to INCLUDE empty strings (or nil for that case) for the >>> elements between to consecutive separators. >>> >>> I can't found a method implementing this in Pharo (in Dolphin it works >>> as I expect). >>> >>> Thank you! >>> >>> Esteban A. Maringolo >>> >>> > |
On 2013-11-21, at 08:18, Stéphane Ducasse <[hidden email]> wrote: > Propose allSubStrings: with a couple of tests and a nice comment. > so that we improve the lib. if it forwards to split: this can be easily done (as pointed out by norbert): $| split: 'foo|bar||foobar|' signature.asc (457 bytes) Download Attachment |
Free forum by Nabble | Edit this page |