Most Smalltalks support the #findTokens:
message on String
s:
'1 2 3' findTokens: ' '. "-> anOrderedCollection('1', '2', '3')"
where the argument can also be multiple delimiters in the string, like '.,;:'
.
Depending on dialect, it may be that #findTokens:
does not take a String
but a Character
:
'1 2 3' findTokens: $ . "note the space" "-> anOrderedCollection('1', '2', '3')
Also, you probably do want to do the splitting before concatenation:
| tempSetValues1 tempSetValues2 |
tempSetValues1 := '1 2 3'.
tempSetValues2 := '3 4 5'.
(tempSetValues1 findTokens: ' '), (tempSetValues2 findTokens: ' ').
This can be generalized as the number of individual input strings gets larger.