On Thu, 25 Oct 2012, Joseph J Alotta wrote:
Greetings. I found a useful method. Only thing is I don't know how to write the character code for no character.
'12%31%%1232' replaceAll: $% with: $. '12.31..1232'
'12%31%%1232' replaceAll: $% with: $* '12*31**1232'
'12%31%%1232' replaceAll: $% with: '' ==> error '12%31%%1232' replaceAll: $% with: Nil ==> error
I looked for a deleteAll: method but there is none for Strings.
Since the size of Strings (and Objects in general) can't be changed in Squeak, and removing characters would change the size, therefore you have to use a method which creates a new object instead of just modifying the receiver. Here are a few possibilities:
'12%31%%1232' copyWithout: $%. '12%31%%1232' copyReplaceAll: '%' with: ''. '12%31%%1232' reject: [ :each | each = $% ]. '12%31%%1232' select: [ :each | each ~= $% ].
Levente
P.S.: While #replaceAll:with: looks useful, it's a bit dangerous, because it changes the receiver. So you'll have to be more careful when you use it.
Thank you for your help.
Joe.