CharacterArray.st
changeset 18464 6b4a8707ff96
parent 18463 8c5f3917b2e8
child 18473 ff8f0323cadd
child 18476 5a7a334213f7
equal deleted inserted replaced
18463:8c5f3917b2e8 18464:6b4a8707ff96
   954     "
   954     "
   955 !
   955 !
   956 
   956 
   957 trimBlanks
   957 trimBlanks
   958     "return a copy of the receiver without leading and trailing spaces.
   958     "return a copy of the receiver without leading and trailing spaces.
   959      This is an ST/V compatibility method."
   959      This is an ST/V compatibility method and an alias for withoutSpaces."
   960 
   960 
   961     ^ self withoutSpaces
   961     ^ self withoutSpaces
   962 
   962 
   963     "
   963     "
   964      '    spaces at beginning' trimBlanks
   964      '    spaces at beginning' trimBlanks
  1237      'hello' copyTo:10
  1237      'hello' copyTo:10
  1238     "
  1238     "
  1239 !
  1239 !
  1240 
  1240 
  1241 withBlanksTrimmed
  1241 withBlanksTrimmed
  1242     "Return a copy of the receiver from which leading and trailing blanks have been trimmed."
  1242     "Return a copy of the receiver from which leading and trailing whitespace have been trimmed.
       
  1243      Notice the bad naming - it is trimming separators, not just blanks.
       
  1244      Added for Squeak compatibility and an alias for withoutSeparators"
  1243 
  1245 
  1244     ^ self withoutSeparators "withoutSpaces"    "/ cg: it seems that squeak cares for any whitespace
  1246     ^ self withoutSeparators "withoutSpaces"    "/ cg: it seems that squeak cares for any whitespace
  1245 
  1247 
  1246     "
  1248     "
  1247      '  hello    world    ' withBlanksTrimmed
  1249      '  hello    world    ' withBlanksTrimmed
  1491     "
  1493     "
  1492 !
  1494 !
  1493 
  1495 
  1494 trimSeparators
  1496 trimSeparators
  1495     "return a copy of the receiver without leading and trailing whiteSpace.
  1497     "return a copy of the receiver without leading and trailing whiteSpace.
  1496      Added for VisualAge compatibility"
  1498      Added for VisualAge compatibility and an alias for withoutSeparators"
  1497 
  1499 
  1498     ^ self withoutSeparators
  1500     ^ self withoutSeparators
  1499 ! !
  1501 ! !
  1500 
  1502 
  1501 !CharacterArray methodsFor:'Compatibility-VW'!
  1503 !CharacterArray methodsFor:'Compatibility-VW'!
  6357      '  hello    wwww   ' withSeparatorsCompacted
  6359      '  hello    wwww   ' withSeparatorsCompacted
  6358      'hel   lo www   w'   withSeparatorsCompacted
  6360      'hel   lo www   w'   withSeparatorsCompacted
  6359     "
  6361     "
  6360 !
  6362 !
  6361 
  6363 
       
  6364 withSeparatorsReplacedBy:replacementCharacter
       
  6365     "return a new string with each separator (whitespace) replaced by replacementCharacter.
       
  6366      Typically used with space as replacementCharacter"
       
  6367 
       
  6368     ^ self species streamContents:[:s |
       
  6369         self do:[:ch |
       
  6370             ch isSeparator ifTrue:[
       
  6371                 s nextPut:replacementCharacter
       
  6372             ] ifFalse:[    
       
  6373                 s nextPut:ch.
       
  6374             ]
       
  6375         ]
       
  6376     ]
       
  6377 
       
  6378     "
       
  6379      'hello wwww'         withSeparatorsReplacedBy:$*
       
  6380      'hello ww ww'        withSeparatorsReplacedBy:$*
       
  6381      '  hello wwww'       withSeparatorsReplacedBy:$*
       
  6382      'hel   lo www   w'   withSeparatorsReplacedBy:$*
       
  6383      'hel
       
  6384  lo www
       
  6385 w'   withSeparatorsReplacedBy:$*
       
  6386     "
       
  6387 !
       
  6388 
  6362 withTabs
  6389 withTabs
  6363     "return a string consisting of the receivers characters
  6390     "return a string consisting of the receivers characters
  6364      where leading spaces are replaced by tabulator characters (assuming 8-col tabs).
  6391      where leading spaces are replaced by tabulator characters (assuming 8-col tabs).
  6365      Notice: if the receiver does not contain any tabs, it is returned unchanged;
  6392      Notice: if the receiver does not contain any tabs, it is returned unchanged;
  6366      otherwise a new string is returned.
  6393      otherwise a new string is returned.
  7453 ! !
  7480 ! !
  7454 
  7481 
  7455 !CharacterArray class methodsFor:'documentation'!
  7482 !CharacterArray class methodsFor:'documentation'!
  7456 
  7483 
  7457 version
  7484 version
  7458     ^ '$Header: /cvs/stx/stx/libbasic/CharacterArray.st,v 1.590 2015-06-08 15:51:54 stefan Exp $'
  7485     ^ '$Header: /cvs/stx/stx/libbasic/CharacterArray.st,v 1.591 2015-06-08 18:33:31 cg Exp $'
  7459 !
  7486 !
  7460 
  7487 
  7461 version_CVS
  7488 version_CVS
  7462     ^ '$Header: /cvs/stx/stx/libbasic/CharacterArray.st,v 1.590 2015-06-08 15:51:54 stefan Exp $'
  7489     ^ '$Header: /cvs/stx/stx/libbasic/CharacterArray.st,v 1.591 2015-06-08 18:33:31 cg Exp $'
  7463 ! !
  7490 ! !
  7464 
  7491 
  7465 
  7492 
  7466 CharacterArray initialize!
  7493 CharacterArray initialize!