--- a/CharacterArray.st Thu Mar 28 12:21:50 2013 +0000
+++ b/CharacterArray.st Mon Apr 01 13:42:45 2013 +0100
@@ -858,8 +858,7 @@
!
trimBlanks
- "return a copy of the receiver without leading
- and trailing spaces.
+ "return a copy of the receiver without leading and trailing spaces.
This is an ST/V compatibility method."
^ self withoutSpaces
@@ -5339,6 +5338,40 @@
"Modified: 2.4.1997 / 18:13:04 / cg"
!
+withSeparatorsCompacted
+ "return a new string with each sequence of whiteSpace replaced by a single space character.
+ Preserves a leading/trailing space."
+
+ ^ self species streamContents:[:s |
+ |skipping|
+
+ skipping := false.
+ 1 to:self size do:[:idx |
+ |char|
+
+ char := self at:idx.
+ char isSeparator ifFalse:[
+ s nextPut:char.
+ skipping := false.
+ ] ifTrue:[
+ skipping ifFalse:[
+ s nextPut:(Character space).
+ skipping := true
+ ].
+ ]
+ ]
+ ]
+
+ "
+ 'hello wwww' withSeparatorsCompacted
+ 'hello wwww' withSeparatorsCompacted
+ ' hello wwww' withSeparatorsCompacted
+ ' hello wwww ' withSeparatorsCompacted
+ ' hello wwww ' withSeparatorsCompacted
+ 'hel lo www w' withSeparatorsCompacted
+ "
+!
+
withTabs
"return a string consisting of the receivers characters
where leading spaces are replaced by tabulator characters (assuming 8-col tabs).
@@ -6306,11 +6339,11 @@
!CharacterArray class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/CharacterArray.st,v 1.495 2013-03-13 14:04:42 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/CharacterArray.st,v 1.497 2013-03-28 16:47:25 cg Exp $'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/libbasic/CharacterArray.st,v 1.495 2013-03-13 14:04:42 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/CharacterArray.st,v 1.497 2013-03-28 16:47:25 cg Exp $'
! !