[squeak-dev] Need an elegant way to solve a simple problem

Levente Uzonyi leves at elte.hu
Tue Sep 22 14:06:34 UTC 2015


If stripping leading blanks is okay, then you can use #withBlanksTrimmed. 
Otherwise you can use the following oneliner:

string copyFrom: 1 to: (string lastIndexOfAnyOf: CharacterSet nonSeparators startingAt: string size ifAbsent: string size)

Levente

On Tue, 22 Sep 2015, Casimiro - GMAIL wrote:

> I have a ByteString line. I want to strip blanks and tabs at end of it. Blanks and tabs allowed between words. MxMatcher looks a bit like using a gun to kill a fly. Any suggestion about a time effective way
> of solving the problem? (obvious way: asOrderedCollection and then backtrack killing spaces & tabs until find non space/tab char).
> 
> Best regards,
> 
> CdAB
> --
> The information contained in this message is confidential and intended to the recipients specified in the headers. If you received this message by error, notify the sender immediately. The unauthorized use,
> disclosure, copy or alteration of this message are strictly forbidden and subjected to civil and criminal sanctions.
> 
> ==
> 
> This email may be signed using PGP key ID: 0x4134A417
> 
>


More information about the Squeak-dev mailing list