All Bundles
String
Resizeable Unicode character string
Implements: Compare, Clone, Stringify
Operations
Code example:
# build and print string
cities_str := "\t\tNapa,";
cities_str += "Fremont,";
cities_str += "Alameda,";
cities_str += "Berkeley,";
cities_str += "Fremont,";
cities_str += "San Carlos,";
cities_str += "Milpitas, ";
cities_str->PrintLine();
# show the string size
cities_str->Size()->PrintLine();
# trim string
cities_str := cities_str->Trim();
cities_str->Size()->PrintLine();
# replace city
cities_str := cities_str->Replace("San Carlos", "Oakland");
cities_str->PrintLine();
# create a substring
start := cities_str->Find("Berkeley");
if(<>start->IsNeg()) {
end := cities_str->Find(start, ',');
if(<>end->IsNeg()) {
city := cities_str->SubString(start, end - start);
"They city found was {$city}"->PrintLine();
}
};
# remove ending comma
cities_str->Pop();
# split string and print values
cities := cities_str->Split(',');
cities->Size()->PrintLine();
# iterate over cities
each(city := cities) {
city->PrintLine();
};
# iterate over cities with an index
each(i : cities) {
city := cities[i];
"{$i}: |{$city}|"->PrintLine();
};
New
Default constructor
New()
Copy constructor
New(string:String)
Parameters
Name | Type | Description |
---|
string | String | string to be copied |
Copy constructor
New(array:Char[])
Parameters
Name | Type | Description |
---|
array | Char[] | array to be copied |
Copy constructor
New(array:Char[], copy:Bool)
Parameters
Name | Type | Description |
---|
array | Char[] | array to be copied |
copy | Bool | if false, use array for value for string otherwise copy values |
Copy constructor
New(array:Char[], offset:Int, length:Int)
Parameters
Name | Type | Description |
---|
array | Char[] | array to be copied |
offset | Int | offset array index offset |
length | Int | number of characters to copy |
Copy constructor
New(bytes:Byte[])
Parameters
Name | Type | Description |
---|
bytes | Byte[] | array to be copied |
Copy constructor
New(bytes:Byte[], offset:Int, length:Int)
Parameters
Name | Type | Description |
---|
bytes | Byte[] | array to be copied |
offset | Int | offset array index offset |
length | Int | number of characters to copy |
Append
Appends a boolean value
method : public : Append(flag:Bool) ~ Nil
Parameters
Name | Type | Description |
---|
flag | Bool | boolean value |
Appends a integer value
method : public : Append(i:Int) ~ Nil
Parameters
Name | Type | Description |
---|
i | Int | integer value |
Appends a float value
method : public : Append(f:Float) ~ Nil
Parameters
Name | Type | Description |
---|
f | Float | float value |
Appends a string
method : public : Append(str:String) ~ Nil
Parameters
Name | Type | Description |
---|
str | String | string object |
Appends a character array
method : public : Append(array:Char[]) ~ Nil
Parameters
Name | Type | Description |
---|
array | Char[] | character array |
Appends a portion of character array
method : public : native : Append(array:Char[], offset:Int, length:Int) ~ Nil
Parameters
Name | Type | Description |
---|
array | Char[] | array to be copied |
offset | Int | offset array index offset |
length | Int | number of characters to copy |
Appends a character array
method : public : native : Append(array:Byte[]) ~ Nil
Parameters
Name | Type | Description |
---|
array | Byte[] | array to be copied |
Appends a portion of byte array
method : public : native : Append(array:Byte[], offset:Int, length:Int) ~ Nil
Parameters
Name | Type | Description |
---|
array | Byte[] | array to be copied |
offset | Int | offset array index offset |
length | Int | number of bytes to copy |
Appends a character
method : public : Append(c:Char) ~ Nil
Parameters
Name | Type | Description |
---|
c | Char | character to append |
Appends a byte
method : public : Append(c:Byte) ~ Nil
Parameters
Name | Type | Description |
---|
c | Byte | byte to append |
Capacity
Gets the current string's storage capacity. That is the number of characters the string will hold before it is resized for growth.
method : public : Capacity() ~ Int
Return
Type | Description |
---|
Int | string capacity |
Clear
Clears string
method : public : Clear() ~ Nil
Clone
Clones the object instance
method : public : Clone() ~ System.String
Return
Type | Description |
---|
String | cloned the object instance |
Compare
Compares two objects
method : public : Compare(rhs:System.Compare) ~ Int
Parameters
Name | Type | Description |
---|
rhs | Compare | compare object |
Return
Type | Description |
---|
Int | 0 if equal, -1 if right-hand side i greater, 1 if left-hand side is greater |
Compress
Compresses a string removing unused space.
method : public : Compress() ~ Nil
Copy
Creates a new instance of the string
method : public : Copy() ~ String
Return
Type | Description |
---|
String | new string instance |
Count
Counts the occurrence of a character
method : public : Count(char:Char) ~ Int
Parameters
Name | Type | Description |
---|
char | Char | character to search for |
Return
Type | Description |
---|
Int | count of occurrences or -1 if not found |
Counts the occurrence of a character
method : public : native : Count(offset:Int, char:Char) ~ Int
Parameters
Name | Type | Description |
---|
offset | Int | search offset |
char | Char | character to search for |
Return
Type | Description |
---|
Int | count of occurrences or -1 if not found |
Delete
Deletes the character at the given index
method : public : Delete(offset:Int) ~ Bool
Parameters
Name | Type | Description |
---|
offset | Int | offset index |
Return
Type | Description |
---|
Bool | true if deleted, false otherwise |
Deletes the characters at the given range
method : public : Delete(offset:Int, length:Int) ~ Bool
Parameters
Name | Type | Description |
---|
offset | Int | offset index |
length | Int | length |
Return
Type | Description |
---|
Bool | true if deleted, false otherwise |
EndsWith
Checks if the string ends with the given character
method : public : EndsWith(char:Char) ~ Bool
Parameters
Name | Type | Description |
---|
char | Char | character to compare |
Return
Type | Description |
---|
Bool | true if ends with character, false otherwise |
Checks if the string ends with the given string
method : public : native : EndsWith(string:String) ~ Bool
Parameters
Name | Type | Description |
---|
string | String | string to check for |
Return
Type | Description |
---|
Bool | true if ends with string, false otherwise |
Equals
Compares two strings
method : public : Equals(rhs:String) ~ Bool
Parameters
Name | Type | Description |
---|
rhs | String | string to compare |
Return
Type | Description |
---|
Bool | true if equal, false otherwise |
Compares a string to an array of values
method : public : Equals(rhs:String[]) ~ Bool
Parameters
Name | Type | Description |
---|
rhs | String[] | array of values to compare |
Return
Type | Description |
---|
Bool | true if at least one match, false otherwise |
EqualsIgnoreCase
Compares two strings, ignoring the case
method : public : EqualsIgnoreCase(rhs:String) ~ Bool
Parameters
Name | Type | Description |
---|
rhs | String | string to compare |
Return
Type | Description |
---|
Bool | true if equal, false otherwise |
Compares a string to an array of values, ignoring case
method : public : EqualsIgnoreCase(rhs:String[]) ~ Bool
Parameters
Name | Type | Description |
---|
rhs | String[] | array of values to compare |
Return
Type | Description |
---|
Bool | true if at least one match, false otherwise |
Error
Print an error string
method : public : Error() ~ Nil
ErrorLine
Print an error string with a newline
method : public : ErrorLine() ~ Nil
Find
Searches for the first occurrence of a character
method : public : Find(char:Char) ~ Int
Parameters
Name | Type | Description |
---|
char | Char | character to search for |
Return
Type | Description |
---|
Int | index of first occurrence, -1 otherwise |
Searches for the first occurrence of a character
method : public : native : Find(offset:Int, char:Char) ~ Int
Parameters
Name | Type | Description |
---|
offset | Int | search offset |
char | Char | character to search for |
Return
Type | Description |
---|
Int | index of first occurrence, -1 otherwise |
Searches for the first occurrence of a string
method : public : Find(find:String) ~ Int
Parameters
Name | Type | Description |
---|
find | String | string to search for |
Return
Type | Description |
---|
Int | index of first occurrence, -1 otherwise |
Searches for the first occurrence of a string
method : public : native : Find(offset:Int, find:String) ~ Int
Parameters
Name | Type | Description |
---|
offset | Int | search index offset |
find | String | string to search for |
Return
Type | Description |
---|
Int | index of first occurrence, -1 otherwise |
FindAll
Searches for all occurrences of a string
method : public : FindAll(find:String) ~ Int[]
Parameters
Name | Type | Description |
---|
find | String | string to search for |
Return
Type | Description |
---|
Int[] | an array of indexes |
FindLast
Searches for the last occurrence of a character
method : public : FindLast(char:Char) ~ Int
Parameters
Name | Type | Description |
---|
char | Char | character to search for |
Return
Type | Description |
---|
Int | index of last occurrence, -1 otherwise |
Searches for the last occurrence of a character
method : public : native : FindLast(offset:Int, char:Char) ~ Int
Parameters
Name | Type | Description |
---|
offset | Int | search offset |
char | Char | character to search for |
Return
Type | Description |
---|
Int | index of last occurrence, -1 otherwise |
First
Returns the first character
method : public : First() ~ Char
Return
Type | Description |
---|
Char | first character |
Get
Returns character at the given index
method : public : native : Get(index:Int) ~ Char
Parameters
Name | Type | Description |
---|
index | Int | index offset |
Return
Type | Description |
---|
Char | character at index |
Has
Searches for the first occurrence of a character
method : public : Has(char:Char) ~ Bool
Parameters
Name | Type | Description |
---|
char | Char | character to search for |
Return
Type | Description |
---|
Bool | true of found, false otherwise |
Searches for the first occurrence of a character
method : public : Has(offset:Int, char:Char) ~ Bool
Parameters
Name | Type | Description |
---|
offset | Int | search offset |
char | Char | character to search for |
Return
Type | Description |
---|
Bool | true of found, false otherwise |
Searches for the first occurrence of a character
method : public : Has(str:String) ~ Bool
Parameters
Name | Type | Description |
---|
str | String | string to search for |
Return
Type | Description |
---|
Bool | true of found, false otherwise |
Searches for the first occurrence of a character
method : public : Has(offset:Int, str:String) ~ Bool
Parameters
Name | Type | Description |
---|
offset | Int | search offset |
str | String | string to search for |
Return
Type | Description |
---|
Bool | true of found, false otherwise |
HashID
Returns a unique hash ID for a given string sequence
method : public : HashID() ~ Int
Return
Type | Description |
---|
Int | hash ID |
Insert
Insert inserts a character
method : public : Insert(index:Int, char:Char) ~ Bool
Parameters
Name | Type | Description |
---|
index | Int | insert offset |
char | Char | character to insert |
Return
Type | Description |
---|
Bool | true if inserted, false otherwise |
Insert inserts a string
method : public : Insert(index:Int, string:String) ~ Bool
Parameters
Name | Type | Description |
---|
index | Int | insert offset |
string | String | string to insert |
Return
Type | Description |
---|
Bool | true if inserted, false otherwise |
Insert inserts a string
method : public : Insert(index:Int, buffer:Char[]) ~ Bool
Parameters
Name | Type | Description |
---|
index | Int | insert offset |
buffer | Char[] | buffer to insert |
Return
Type | Description |
---|
Bool | true if inserted, false otherwise |
IsEmpty
Returns rather the string is empty
method : public : IsEmpty() ~ Bool
Return
Type | Description |
---|
Bool | true if empty, false otherwise |
IsFloat
Checks to see if the string can be represented as an float
method : public : IsFloat() ~ Bool
Return
Type | Description |
---|
Bool | true if the string can be represented as an float, false otherwise |
IsInt
Checks to see if the string can be represented as an interger
method : public : native : IsInt() ~ Bool
Return
Type | Description |
---|
Bool | true if the string can be represented as an interger, false otherwise |
Justify
Justify if word length is then width
method : public : Justify(width:Int, is_left:Bool) ~ String
Parameters
Name | Type | Description |
---|
width | Int | width to justify to |
is_left | Bool | if true, justify left, right otherwise |
Return
Type | Description |
---|
String | padded string |
Last
Returns the last character
method : public : native : Last() ~ Char
Return
Type | Description |
---|
Char | last character |
Lines
Splits a string into lines
method : public : native : Lines() ~ String[]
Return
Pad
Pads a string with a character
method : public : Pad(char:Char, num:Int, is_left:Bool) ~ String
Parameters
Name | Type | Description |
---|
char | Char | character to pad with |
num | Int | number of character to pad |
is_left | Bool | if true, pad left, otherwise pad right |
Return
Type | Description |
---|
String | padded string |
Pop
Pops the last character from the string reducing the size by 1
method : public : native : Pop() ~ Char
Return
Type | Description |
---|
Char | last character of the string |
Print
Print a string
method : public : Print() ~ Nil
PrintLine
Prints values
function : PrintLine(v:String[]) ~ Nil
Parameters
Name | Type | Description |
---|
v | String[] | values to print |
Print a string with a newline
method : public : PrintLine() ~ Nil
Remove
Removes the first occurrence the search string
method : public : Remove(find:String) ~ String
Parameters
Name | Type | Description |
---|
find | String | string to search for |
Return
Type | Description |
---|
String | new string instance |
Removes all matching characters from a string
method : public : Remove(char:Char) ~ String
Parameters
Name | Type | Description |
---|
char | Char | character to remove |
Return
Type | Description |
---|
String | string with matching characters removed |
RemoveAll
Removes all occurrences the search string
method : public : RemoveAll(find:String) ~ String
Parameters
Name | Type | Description |
---|
find | String | string to search for |
Return
Type | Description |
---|
String | new string instance |
Removes all occurrences the search character
method : public : RemoveAll(find:Char) ~ String
Parameters
Name | Type | Description |
---|
find | Char | character to search for |
Return
Type | Description |
---|
String | new string instance |
Replace
Replaces the first occurrence the search string
method : public : Replace(find:String, replace:String) ~ String
Parameters
Name | Type | Description |
---|
find | String | string to search for |
replace | String | string to replace with |
Return
Type | Description |
---|
String | new string instance |
ReplaceAll
Replaces all occurrences the search string
method : public : ReplaceAll(find:String, replace:String) ~ String
Parameters
Name | Type | Description |
---|
find | String | string to search for |
replace | String | string to replace with |
Return
Type | Description |
---|
String | new string instance |
Replaces all occurrences the search string
method : public : native : ReplaceAll(find:Char, replace:Char) ~ String
Parameters
Name | Type | Description |
---|
find | Char | character to search for |
replace | Char | character to replace with |
Return
Type | Description |
---|
String | new string instance |
Reverse
Reverses a string
method : public : native : Reverse() ~ String
Return
Type | Description |
---|
String | reversed string |
Set
Sets character at the given index
method : public : Set(char:Char, index:Int) ~ Bool
Parameters
Name | Type | Description |
---|
char | Char | charter to set |
index | Int | index offset |
Return
Type | Description |
---|
Bool | true if successful, false otherwise |
SetFloatFormat
Set floating point string format.
function : SetFloatFormat(format:Number->Format) ~ Nil
Parameters
SetFloatPrecision
Set floating point string precision.
function : SetFloatPrecision(precision:Int) ~ Nil
Parameters
Name | Type | Description |
---|
precision | Int | decimal precision |
SetIntFormat
Set integer string format.
function : SetIntFormat(format:Number->Format) ~ Nil
Parameters
Size
Return the size of the string
method : public : Size() ~ Int
Return
Type | Description |
---|
Int | size of the string |
Split
Splits a string based upon delimiter
method : public : native : Split(delim:String) ~ String[]
Parameters
Name | Type | Description |
---|
delim | String | splitting delimiter |
Return
Type | Description |
---|
String[] | array of split sub strings |
Splits a string based upon delimiter
method : public : native : Split(delim:Char) ~ String[]
Parameters
Name | Type | Description |
---|
delim | Char | splitting delimiter |
Return
Type | Description |
---|
String[] | array of split sub strings |
StartsWith
Checks if the string starts with the given character
method : public : StartsWith(char:Char) ~ Bool
Parameters
Name | Type | Description |
---|
char | Char | character to compare |
Return
Type | Description |
---|
Bool | true if starts with character, false otherwise |
Checks if the string starts with the given string
method : public : StartsWith(string:String) ~ Bool
Parameters
Name | Type | Description |
---|
string | String | string to check for |
Return
Type | Description |
---|
Bool | true if starts with string, false otherwise |
SubString
Creates a sub-string
method : public : SubString(length:Int) ~ String
Parameters
Name | Type | Description |
---|
length | Int | max length of sub-string |
Return
Type | Description |
---|
String | sub-string |
Creates a sub-string
method : public : SubString(offset:Int, length:Int) ~ String
Parameters
Name | Type | Description |
---|
offset | Int | index offset |
length | Int | max length of sub-string |
Return
Type | Description |
---|
String | sub-string |
ToBool
Parses the string into a boolean
method : public : ToBool() ~ Bool
Return
Type | Description |
---|
Bool | boolean value |
ToByteArray
Returns a byte array representation of the String
method : public : native : ToByteArray() ~ Byte[]
Return
Type | Description |
---|
Byte[] | byte array |
ToCharArray
Returns a character array representation of the String
method : public : ToCharArray() ~ Char[]
Return
Type | Description |
---|
Char[] | character array |
ToFloat
Parses the string into a float
method : public : ToFloat() ~ Float
Return
Type | Description |
---|
Float | float value |
ToInt
Parses the string into an integer
method : public : ToInt() ~ Int
Return
Type | Description |
---|
Int | integer value |
Parses the string into an integer
method : public : ToInt(base:Int) ~ Int
Parameters
Name | Type | Description |
---|
base | Int | base radix |
Return
Type | Description |
---|
Int | integer value |
ToLower
Transforms a to lower case
method : public : native : ToLower() ~ String
Return
Type | Description |
---|
String | lower case string |
ToString
Returns string of self
method : public : ToString() ~ String
Return
Type | Description |
---|
String | string of self |
Formats an array of string
function : native : ToString(v:String[]) ~ String
Parameters
Name | Type | Description |
---|
v | String[] | string array |
ToUpper
Transforms a to upper case
method : public : native : ToUpper() ~ String
Return
Type | Description |
---|
String | upper case string |
Trim
Removes all leading and trailing white space
method : public : native : Trim() ~ String
Return
Type | Description |
---|
String | trimmed string |
TrimBack
Removes all trailing white space
method : public : native : TrimBack() ~ String
Return
Type | Description |
---|
String | trimmed string |
TrimFront
Removes all leading white space
method : public : native : TrimFront() ~ String
Return
Type | Description |
---|
String | trimmed string |