findTokens: vs explode:
Lic. Edgar J. De Cleene
edgardec2001 at yahoo.com.ar
Fri Sep 8 19:50:13 UTC 2006
Ron Teitelbaum puso en su mail :
> Hi all,
>
> Earlier we discussed a replacement for my explode method. findTokens: was
> suggested but
>
> ' version [0] EXPLICIT Version DEFAULT v1,' findTokens:
> EXPLICIT¹ =
> an OrderedCollection(' version [0] ' ' Version D' 'FAU' ' v1,')
>
> but
>
> ' version [0] EXPLICIT Version DEFAULT v1,' explode: EXPLICIT¹
> =
> an OrderedCollection(' version [0] ' ' Version DEFAULT v1,')
>
> I can see that findTokens: removes all instances of each character. Which is
> not what I¹m looking for.
>
> Does anyone have any other suggestions?
>
> Ron Teitelbaum
>
> Ron:
> Hope this helps, sure someone could do better
>
> In String, accesing category
>
explode: aString
| pos tokens |
tokens := OrderedCollection new.
pos := self findString: aString startingAt: 1.
tokens
add: (self copyFrom: 1 to: pos - 1).
pos := pos + aString size.
tokens
add: (self copyFrom: pos to: self size).
^ tokens
' version [0] EXPLICIT Version DEFAULT v1,' explode:
'EXPLICIT' an OrderedCollection(' version [0] ' ' Version
DEFAULT v1,')
I note what copy from yours and paste again in Squeak the delimiters of
EXPLICIT was different to single quote
Edgar
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20060908/6d37258e/attachment.htm
More information about the Squeak-dev
mailing list
|