#FEATURE by cg
authorClaus Gittinger <cg@exept.de>
Mon, 23 Oct 2017 15:01:55 +0200
changeset 22323 d289144495cb
parent 22322 e8e314fee20f
child 22324 61d66473b029
#FEATURE by cg class: CharacterArray added: #withoutSuffix:
CharacterArray.st
--- a/CharacterArray.st	Mon Oct 23 12:59:48 2017 +0200
+++ b/CharacterArray.st	Mon Oct 23 15:01:55 2017 +0200
@@ -347,7 +347,6 @@
     "Created: 3.8.1997 / 18:16:40 / cg"
 ! !
 
-
 !CharacterArray class methodsFor:'cleanup'!
 
 lowSpaceCleanup
@@ -609,7 +608,6 @@
     "
 ! !
 
-
 !CharacterArray class methodsFor:'pattern matching'!
 
 matchEscapeCharacter
@@ -1015,7 +1013,6 @@
     ^ Unicode32String
 ! !
 
-
 !CharacterArray methodsFor:'Compatibility-ANSI'!
 
 addLineDelimiters
@@ -4955,8 +4952,6 @@
 ! !
 
 
-
-
 !CharacterArray methodsFor:'matching - glob expressions'!
 
 compoundMatch:aString
@@ -6433,7 +6428,6 @@
     "Modified: 17.4.1997 / 12:50:23 / cg"
 ! !
 
-
 !CharacterArray methodsFor:'special string converting'!
 
 asUnixFilenameString
@@ -7459,6 +7453,23 @@
     "
 !
 
+withoutSuffix:aString
+    "if the receiver endsWith aString, return a copy without it.
+     Otherwise return the receiver"
+
+    (self endsWith:aString) ifTrue:[
+        ^ self copyButLast:aString size
+    ].
+    ^ self
+
+    "
+     'helloworld' withoutSuffix:'world'
+     'helloworld' withoutSuffix:'foo'
+    "
+
+    "Created: / 23-10-2017 / 15:01:37 / cg"
+!
+
 withoutTrailingSeparators
     "return a copy of myself without trailing separators.
      Notice: this does remove tabs, newline or any other whitespace.
@@ -7477,7 +7488,6 @@
     "
 ! !
 
-
 !CharacterArray methodsFor:'substring searching'!
 
 findRangeOfString:subString
@@ -8286,7 +8296,6 @@
     ^ aVisitor visitString:self with:aParameter
 ! !
 
-
 !CharacterArray class methodsFor:'documentation'!
 
 version