Useful API Functions
Version vom 27. Juli 2019, 14:41 Uhr von Cg (Diskussion | Beiträge) (→copyBetween:and:caseSensitive:)
Inhaltsverzeichnis
String[Bearbeiten]
Reference: String Class Documentation
CharacterArray (superclass)
Collection (superclass)
Copying[Bearbeiten]
Notice: except when written otherwise, all indices are 1-based. Valid indices range from 1 to the string's size.
copyFrom:to:[Bearbeiten]
aString copyFrom:startIndex to:endIndex aString.copyFrom_to(startIndex, endIndex) [JS]
Example:
'hello world' copyFrom:1 to:5. => 'hello'
copyFrom:count:[Bearbeiten]
aString copyFrom:startIndex count:numChars aString.copyFrom_count(startIndex, numChars) [JS]
Example:
'hello world' copyFrom:7 count:3. => 'wor'
copyFrom:[Bearbeiten]
aString copyFrom:startIndex' aString.copyFrom(startIndex) [JS]
Example:
'hello world' copyFrom:6. => ' world'
copyTo:[Bearbeiten]
aString copyTo:endIndex aString.copyTo(endIndex) [JS]
Example:
'hello world' copyTo:6. => 'hello '
copyBetween:and:caseSensitive:[Bearbeiten]
aString copyBetween:leftString and:rightString caseSensitive:boolean aString.copyBetween_and_caseSensitive(leftString, rightString, boolean) [JS]
Example:
'hello small world' copyBetween:'hello' and:'world' caseSensitive:true. => ' small '
'helloworld' copyBetween:'hello' and:'world' caseSensitive:true. =>
'hello small World' copyBetween:'hello' and:'world' caseSensitive:true. => nil
'hello small World' copyBetween:'hello' and:'world' caseSensitive:false. => ' small '
copyReplaceString: withString:[Bearbeiten]
aString copyReplaceString:oldString withString:newString aString. copyReplaceString_ withString(oldString, newString) [JS]
Example:
'hello small world' copyReplaceString:'small' withString:'big' => ' hello big world '
'hello small world' copyReplaceString:'big' withString:'bigger' => ' hello small world '
Concatenation[Bearbeiten]
, (comma)[Bearbeiten]
string1 , string2 string1 + string2 [JS]
Example:
'hello', ' ' , 'world' => 'hello world'