Category: Collections-Text
Superclass: CharacterArray
My instances represent 8-bit character strings. Being a very common case, they are particularly optimized. Note that, if you care about multilingualization, you should treat String only as an encoded representation of a UnicodeString. The I18N package adds more Unicode-friendliness to the system so that encoding and decoding is performed automatically in more cases. In that case, String represents a case when the encoding is either unknown, irrelevant, or assumed to be the system default.

Method category index

instance creation (class)
multibyte encodings (class)
accessing (instance)
basic (instance)
built ins (instance)
CObject (instance)
converting (instance)
filesystem (instance)
printing (instance)
regex (instance)
still unclassified (instance)
testing functionality (instance)

instance creation (class)

fromCData: aCObject
Answer a String containing the bytes starting at the location pointed to by aCObject, up to the first NUL character.

fromCData: aCObject size: anInteger

Answer a String containing anInteger bytes starting at the location pointed to by aCObject

top


multibyte encodings (class)

isUnicode
Answer false; the receiver stores bytes (i.e. an encoded form), not characters.

top


accessing (instance)

byteAt: index
Answer the ascii value of index-th character variable of the receiver

byteAt: index put: value

Store (Character value: value) in the index-th indexed instance variable of the receiver

top


basic (instance)

, aString
Answer a new instance of an ArrayedCollection containing all the elements in the receiver, followed by all the elements in aSequenceableCollection

= aCollection

Answer whether the receiver's items match those in aCollection

indexOf: anElement startingAt: anIndex

Answer the first index > anIndex which contains anElement. Invoke exceptionBlock and answer its result if no item is found

indexOf: anElement startingAt: anIndex ifAbsent: exceptionBlock

Answer the first index > anIndex which contains anElement. Invoke exceptionBlock and answer its result if no item is found

top


built ins (instance)

asCData: aCType
Allocate memory with malloc for a NULL-terminated copy of the receiver, and return a pointer to it as a CObject of the given type.

at: anIndex

Answer the index-th indexed instance variable of the receiver

at: anIndex ifAbsent: aBlock

Answer the index-th indexed instance variable of the receiver

at: anIndex put: value

Store value in the index-th indexed instance variable of the receiver

basicAt: anIndex

Answer the index-th indexed instance variable of the receiver. This method must not be overridden, override at: instead

basicAt: anIndex put: value

Store value in the index-th indexed instance variable of the receiver This method must not be overridden, override at:put: instead

hash

Answer an hash value for the receiver

replaceFrom: start to: stop with: aString startingAt: replaceStart

Replace the characters from start to stop with new characters whose ASCII codes are contained in aString, starting at the replaceStart location of aString

replaceFrom: start to: stop withByteArray: byteArray startingAt: replaceStart

Replace the characters from start to stop with new characters whose ASCII codes are contained in byteArray, starting at the replaceStart location of byteArray

similarityTo: aString

Answer a number that denotes the similarity between aString and the receiver. 0 indicates equality, negative numbers indicate some difference. Implemented as a primitive for speed.

size

Answer the size of the receiver

top


CObject (instance)

asCData
Allocate memory with malloc for a NULL-terminated copy of the receiver, and return a pointer to it as a CChar.

top


converting (instance)

asByteArray
Return the receiver, converted to a ByteArray of ASCII values

asString

But I already am a String! Really!

asSymbol

Returns the symbol corresponding to the receiver

encoding

Answer the encoding of the receiver. This is not implemented unless you load the Iconv package.

top


filesystem (instance)

/ aName
Answer a File object as appropriate for a file named 'aName' in the directory represented by the receiver.

asFile

Answer a File object for the file whose name is in the receiver.

top


printing (instance)

displayOn: aStream
Print a representation of the receiver on aStream. Unlike #printOn:, this method strips extra quotes.

displayString

Answer a String representing the receiver. For most objects this is simply its #printString, but for CharacterArrays and characters, superfluous dollars or extra pair of quotes are stripped.

isLiteralObject

Answer whether the receiver is expressible as a Smalltalk literal.

printOn: aStream

Print a representation of the receiver on aStream

storeLiteralOn: aStream

Store a Smalltalk literal compiling to the receiver on aStream

storeOn: aStream

Store Smalltalk code compiling to the receiver on aStream

top


regex (instance)

=~ pattern
Answer a RegexResults object for matching the receiver against the Regex or String object pattern.

allOccurrencesOfRegex: pattern

Find all the matches of pattern within the receiver and collect them into an OrderedCollection.

allOccurrencesOfRegex: pattern do: aBlock

Find all the matches of pattern within the receiver and pass the RegexResults objects to aBlock.

allOccurrencesOfRegex: pattern from: from to: to

Find all the matches of pattern within the receiver and within the given range of indices. Collect them into an OrderedCollection, which is then returned.

allOccurrencesOfRegex: pattern from: from to: to do: aBlock

Find all the matches of pattern within the receiver and within the given range of indices. For each match, pass the RegexResults object to aBlock.

asRegex

Answer the receiver, converted to a Regex object.

copyFrom: from to: to replacingAllRegex: pattern with: aStringOrBlock

Returns the substring of the receiver between from and to. Any match of pattern in that part of the string is replaced using aStringOrBlock as follows: if it is a block, a RegexResults object is passed, while if it is a string, %n sequences are replaced with the captured subexpressions of the match (as in #%).

copyFrom: from to: to replacingRegex: pattern with: aStringOrBlock

Returns the substring of the receiver between from and to. If pattern has a match in that part of the string, the match is replaced using aStringOrBlock as follows: if it is a block, a RegexResults object is passed, while if it is a string, %n sequences are replaced with the captured subexpressions of the match (as in #%).

copyReplacingAllRegex: pattern with: aStringOrBlock

Returns the receiver after replacing all the matches of pattern (if any) using aStringOrBlock as follows: if it is a block, a RegexResults object is passed, while if it is a string, %n sequences are replaced with the captured subexpressions of the match (as in #%).

copyReplacingRegex: pattern with: aStringOrBlock

Returns the receiver after replacing the first match of pattern (if any) using aStringOrBlock as follows: if it is a block, a RegexResults object is passed, while if it is a string, %n sequences are replaced with the captured subexpressions of the match (as in #%).

indexOfRegex: regexString

If an occurrence of the regex is present in the receiver, return the Interval corresponding to the leftmost-longest match. Otherwise return nil.

indexOfRegex: regexString from: from to: to

If an occurrence of the regex is present in the receiver, return the Interval corresponding to the leftmost-longest match occurring within the given range of indices. Otherwise return nil.

indexOfRegex: regexString from: from to: to ifAbsent: excBlock

If an occurrence of the regex is present in the receiver, return the Interval corresponding to the leftmost-longest match occurring within the given indices. Otherwise, evaluate excBlock and return the result.

indexOfRegex: regexString ifAbsent: excBlock

If an occurrence of the regex is present in the receiver, return the Interval corresponding to the leftmost-longest match. Otherwise, evaluate excBlock and return the result.

indexOfRegex: regexString startingAt: index

If an occurrence of the regex is present in the receiver, return the Interval corresponding to the leftmost-longest match starting after the given index. Otherwise return nil.

indexOfRegex: regexString startingAt: index ifAbsent: excBlock

If an occurrence of the regex is present in the receiver, return the Interval corresponding to the leftmost-longest match starting after the given index. Otherwise, evaluate excBlock and return the result.

matchRegex: pattern

Answer whether the receiver is an exact match for the pattern. This means that the pattern is implicitly anchored at the beginning and the end.

matchRegex: pattern from: from to: to

Answer whether the given range of indices is an exact match for the pattern. This means that there is a match starting at from and ending at to (which is not necessarily the longest match starting at from).

occurrencesOfRegex: pattern

Returns count of how many times pattern repeats in the receiver.

occurrencesOfRegex: pattern from: from to: to

Return a count of how many times pattern repeats in the receiver within the given range of index.

occurrencesOfRegex: pattern startingAt: index

Returns count of how many times pattern repeats in the receiver, starting the search at the given index.

onOccurrencesOfRegex: pattern do: body

Find all the matches of pattern within the receiver and, for each match, pass the RegexResults object to aBlock.

onOccurrencesOfRegex: pattern from: from to: to do: aBlock

Find all the matches of pattern within the receiver and within the given range of indices. For each match, pass the RegexResults object to aBlock.

replacingAllRegex: pattern with: aStringOrBlock

Returns the receiver if the pattern has no match in it. Otherwise, any match of pattern in that part of the string is replaced using aStringOrBlock as follows: if it is a block, a RegexResults object is passed, while if it is a string, %n sequences are replaced with the captured subexpressions of the match (as in #%).

replacingRegex: pattern with: aStringOrBlock

Returns the receiver if the pattern has no match in it. If it has a match, it is replaced using aStringOrBlock as follows: if it is a block, a RegexResults object is passed, while if it is a string, %n sequences are replaced with the captured subexpressions of the match (as in #%).

searchRegex: pattern

A synonym for #=~. Answer a RegexResults object for matching the receiver against the Regex or String object pattern.

searchRegex: pattern from: from to: to

Answer a RegexResults object for matching the receiver against the Regex or String object pattern, restricting the match to the specified range of indices.

searchRegex: pattern startingAt: anIndex

Answer a RegexResults object for matching the receiver against the Regex or String object pattern, starting the match at index anIndex.

tokenize: pattern

Split the receiver at every occurrence of pattern. All parts that do not match pattern are separated and stored into an Array of Strings that is returned.

tokenize: pattern from: from to: to

Split the receiver at every occurrence of pattern (considering only the indices between from and to). All parts that do not match pattern are separated and stored into an Array of Strings that is returned.

~ pattern

Answer whether the receiver matched against the Regex or String object pattern.

top


still unclassified (instance)

escapeRegex
Answer the receiver with all regex special characters escaped by a backslash.

top


testing functionality (instance)

isString
Answer `true'.

top