--- a/CharacterArray.st Fri May 28 14:01:13 1999 +0200
+++ b/CharacterArray.st Mon May 31 12:41:12 1999 +0200
@@ -2080,6 +2080,38 @@
"
!
+replString:subString withString:newString
+ "return a copy of the receiver, with all sequences of subString replaced
+ by newString (i.e. slice in the newString in place of the oldString)."
+
+ |tmpStream idx idx1|
+
+ tmpStream := WriteStream on:(self class new).
+ idx := 1.
+ [idx ~~ 0] whileTrue:[
+ idx1 := idx.
+ idx := self indexOfSubCollection:subString startingAt:idx.
+ idx ~~ 0 ifTrue:[
+ tmpStream nextPutAll:(self copyFrom:idx1 to:idx-1).
+ tmpStream nextPutAll:newString.
+ idx := idx + subString size
+ ]
+ ].
+ tmpStream nextPutAll:(self copyFrom:idx1).
+ ^ tmpStream contents
+
+ "
+ '12345678901234567890' replString:'123' withString:'OneTwoThree'
+ '12345678901234567890' replString:'123' withString:'*'
+ '12345678901234567890' replString:'234' withString:'foo'
+
+ ('a string with spaces' replChar:$ withString:' foo ')
+ replString:'foo' withString:'bar'
+ "
+
+ "Modified: / 31.5.1999 / 12:33:59 / cg"
+!
+
trimBlanks
"return a copy of the receiver without leading
and trailing spaces.
@@ -5294,6 +5326,6 @@
!CharacterArray class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/CharacterArray.st,v 1.159 1999-05-08 14:32:08 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/CharacterArray.st,v 1.160 1999-05-31 10:41:12 cg Exp $'
! !
CharacterArray initialize!