[Newbies] Remove trailing spaces of aString

H. Hirzel hannes.hirzel at gmail.com
Fri Apr 27 21:20:26 UTC 2012


Thank you Tobias for answer
  'abc ' withoutTrailingBlanks    "Squeak"

Blake for pointing out the Pharo method

   ''abc  '   trimRight    "Pharo"


The reminder about MethodFinder is useful.
MethodFinder methodFor: { {'abc  '} . 'abc' }

--Hannes

On 4/27/12, blake <dsblakewatson at gmail.com> wrote:
> Sorry, Hannes,
>
> I happened to have Pharo up right then so I used that. Not thrilled
> they have different methods for this.
>
> ===Blake===
>
> On Fri, Apr 27, 2012 at 12:28 PM, H. Hirzel <hannes.hirzel at gmail.com>
> wrote:
>> Blake,
>>
>> This is actually the problem
>>
>> 'abc    ' trimRight
>>
>> does not work in
>>
>> 4.3, Update 11860  (= the version in the one-click download from
>> http://ftp.squeak.org/4.3/Squeak-4.3-All-in-One.zip )
>>
>> "unknown selector"
>>
>> Which version do you use?
>>
>> --Hannes
>>
>> On 4/27/12, blake <dsblakewatson at gmail.com> wrote:
>>> In a Workspace, try:
>>>
>>> 'abc    ' trimRight
>>>
>>> There's also trimLeft and a trimBoth. You can browse the String class
>>> to see them. You can also see the code in there which gives a hint as
>>> to how easy it is to modify for different character.
>>>
>>> ===Blake===
>>>
>>> On Fri, Apr 27, 2012 at 8:27 AM, H. Hirzel <hannes.hirzel at gmail.com>
>>> wrote:
>>>> Hello
>>>>
>>>> I use Squeak 4.3, Update 11860.
>>>>
>>>> I want to remove the trailing spaces and or tabs and LF of a String
>>>>
>>>> something like
>>>> 'abc
>>>> '
>>>>
>>>> should just be
>>>> 'abc'.
>>>>
>>>> If I remember  that there was a method in class String to something
>>>> like this. Is this correct?
>>>> Is there a package with additional String convenience methods?
>>>>
>>>> Thank you for the answer in advance
>>>> --Hannes
>>>> _______________________________________________
>>>> Beginners mailing list
>>>> Beginners at lists.squeakfoundation.org
>>>> http://lists.squeakfoundation.org/mailman/listinfo/beginners
>>> _______________________________________________
>>> Beginners mailing list
>>> Beginners at lists.squeakfoundation.org
>>> http://lists.squeakfoundation.org/mailman/listinfo/beginners
>>>
>> _______________________________________________
>> Beginners mailing list
>> Beginners at lists.squeakfoundation.org
>> http://lists.squeakfoundation.org/mailman/listinfo/beginners
> _______________________________________________
> Beginners mailing list
> Beginners at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/mailman/listinfo/beginners
>


More information about the Beginners mailing list