Well, Tokenish isn't a class, it's a class variable containing a list of all the characters considered 'tokenish' (see Character>>#tokenish).
You really shouldn't find yourself using constructions like
String classPool at: #CaseSensitiveOrder
.. to do so implies some pretty serious misunderstanding somewhere along the line.
If you want to find a substring you really ought to use String>>#findString:startingAt:caseSensitive: if you need to control the case sensitivity, or just String>>#findString:startingAt: if the default of true is ok.
Assuming your problem is a bit more general in that you need to split two-word phrases that have been agglomerated, we might try
|input firstOne| input := 'complexgrammar'. firstOne := 'complex'.
^String streamContents: [:strm| strm nextPutAll: firstOne capitalized. strm space. strm nextPutAll: (input allButFirst: firstOne size) capitalized]
Note that this doesn't do any checking of the existence of anything after the firstOne string, or even that firstOne exists within input.
On 2023-09-18, at 6:33 AM, gettimothy via Squeak-dev squeak-dev@lists.squeakfoundation.org wrote:
fwiw, here is what I came up with.
If anybody knows an elegant way to do this, much appreciated.
|str f l r| str := 'complexgrammar'. f := (str from: 1 to:(str findSubstring: 'grammar' in:str startingAt: 1 matchTable: ( String classPool at: #CaseSensitiveOrder)) -1). l := (str from: (str findSubstring: 'grammar' in:str startingAt: 1 matchTable: ( String classPool at: #CaseSensitiveOrder)) to:(str size)). r := (f capitalized) , ' ' , (l capitalized) . r inspect
---- On Mon, 18 Sep 2023 09:16:02 -0400 gettimothy via Squeak-dev squeak-dev@lists.squeakfoundation.org wrote ---
Hi folks.
I am trying to figure out how to separate some words in a string 'complexgrammar' so I can print Complex Grammar.
looking for solutions, I find Tokenish, a class that does nothing with no comment.
I think it may be a former colleague of mine.
tim -- tim Rowledge; tim@rowledge.org; http://www.rowledge.org/tim Calm down -- it's only ones and zeros.