Class String


back
break: separators  | words word |
" break string into words, using separators "
word <- ''.
words <- List new.
self do: [:c |
(separators includes: c)
ifTrue: [
(word size > 0) " found a word "
ifTrue: [ words add: word.
word <- '' ] ]
ifFalse: [ word <- word + c asString ] ].
" maybe a last word "
(word size > 0) ifTrue: [ words add: word ].
^ words