new: #withoutQuotes
authorStefan Vogel <sv@exept.de>
Sat, 28 Jul 2007 20:09:44 +0200
changeset 10671 90b197d23f1b
parent 10670 5d8c5bab6e25
child 10672 b6230a13035b
new: #withoutQuotes
CharacterArray.st
--- a/CharacterArray.st	Sat Jul 28 19:25:04 2007 +0200
+++ b/CharacterArray.st	Sat Jul 28 20:09:44 2007 +0200
@@ -3813,6 +3813,7 @@
     "Modified: 17.4.1997 / 12:50:23 / cg"
 ! !
 
+
 !CharacterArray methodsFor:'special string converting'!
 
 chopTo:maxLen
@@ -4469,6 +4470,26 @@
     "
 !
 
+withoutQuotes
+    "remove quotes ("" and ') from the front and the end of myself"
+
+    |result quote|
+
+    result := self.
+    ((result startsWith:$") or:[(result startsWith:$')]) ifTrue:[
+        quote := result at:1.
+        result := result copyFrom:2.
+        (result endsWith:quote) ifTrue:[
+            result := result copyWithoutLast:1
+        ].
+    ].
+    ^ result
+
+"/    '"hello"' withoutQuotes   
+"/    '''hello''' withoutQuotes 
+"/    'hello' withoutQuotes 
+!
+
 withoutSeparators
     "return a copy of myself without leading and trailing whitespace.
      (but whiteSpace in-between is preserved)
@@ -5257,7 +5278,7 @@
 !CharacterArray class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/CharacterArray.st,v 1.359 2007-05-30 10:39:23 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/CharacterArray.st,v 1.360 2007-07-28 18:09:44 stefan Exp $'
 ! !
 
 CharacterArray initialize!