[Newbies] Collection in Smalltalk

Herbert König herbertkoenig at gmx.net
Thu Sep 25 08:12:51 UTC 2008


Hello Alex,


AC> Thanks. I'll try to start with the indexing table for each character first.
AC> Anyway do you know how to split string based on more than 1
AC> character, for example I want to split string based on some
AC> punctuation. I have tried using tokenBasedOn, but still can not
AC> figured out how to use it for more than 1 separator. 

String>>findTokens: is your friend here.

I have a code fragment which reads

tokens := comment asLowercase findTokens: mySeparators

As I use this fairly often, someplace I have code to initialise
mySeparators like:

mySeparators := Array new: 13
mySeparators at: 1 put: $- ; at: 2 put: $( .....
and so on.



Cheers,

Herbert   



More information about the Beginners mailing list