Search code examples
smalltalkpharodolphin-smalltalk

findTokens: in Pharo versus Dolphin Smalltalk


I want to split a String in Pharo 4. My input is

'a %% b %% c %%% d %% e %% f' 

and I want to get

#('a %% b %% c' 'd %% e %% f')

thus the separator is ' %%% '

In Dolphin 7 it works nice:

'a %% b %% c %%% d %% e %% f' subStrings: ' %%% '
#('a %% b %% c' 'd %% e %% f')

But in Pharo 4 seems to be broken:

'a %% b %% c %%% d %% e %% f' subStrings: ' %%% '
"#('a' 'b' 'c' 'd' 'e' 'f')"

There is a way to get the Dolphin behavior in Pharo?


Solution

  • Try

    'a %% b %% c %%% d %% e %% f' splitOn: ' %%% '
    

    It also works with

    'a %% b %% c %%% d %% e %% f %%% g %% h %% i' splitOn: ' %%% '