v2026.6.0
All Bundles
Bundle Core runtime library providing primitive types (Bool, Byte, Char, Int, Float, String), base collections, and system utilities. Every Objeck program links against this bundle automatically via lang.obl.

String

Resizeable Unicode character string

Implements: Compare, Clone, Stringify
# 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();
};

Operations

Append #

Appends a boolean value

method : public : Append(flag:Bool) ~ Nil

Parameters

NameTypeDescription
flagBoolboolean value

Append #

Appends a integer value

method : public : Append(i:Int) ~ Nil

Parameters

NameTypeDescription
iIntinteger value

Append #

Appends a float value

method : public : Append(f:Float) ~ Nil

Parameters

NameTypeDescription
fFloatfloat value

Append #

Appends a string

method : public : Append(str:String) ~ Nil

Parameters

NameTypeDescription
strStringstring object

Example

s := "Hello";
s->Append(", World");
s->PrintLine();  # Hello, World

Append #

Appends a character array

method : public : Append(array:Char[]) ~ Nil

Parameters

NameTypeDescription
arrayCharcharacter array

Append # native

Appends a portion of character array

method : public : native : Append(array:Char[], offset:Int, length:Int) ~ Nil

Parameters

NameTypeDescription
arrayChararray to be copied
offsetIntoffset array index offset
lengthIntnumber of characters to copy

Append # native

Appends a character array

method : public : native : Append(array:Byte[]) ~ Nil

Parameters

NameTypeDescription
arrayBytearray to be copied

Append # native

Appends a portion of byte array

method : public : native : Append(array:Byte[], offset:Int, length:Int) ~ Nil

Parameters

NameTypeDescription
arrayBytearray to be copied
offsetIntoffset array index offset
lengthIntnumber of bytes to copy

Append #

Appends a character

method : public : Append(c:Char) ~ Nil

Parameters

NameTypeDescription
cCharcharacter to append

Append #

Appends a byte

method : public : Append(c:Byte) ~ Nil

Parameters

NameTypeDescription
cBytebyte 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

TypeDescription
Intstring capacity

Clear #

Clears string

method : public : Clear() ~ Nil

Clone #

Clones the object instance

method : public : Clone() ~ System.String

Return

TypeDescription
Stringcloned the object instance

Compare #

Compares two objects

method : public : Compare(rhs:System.Compare) ~ Int

Parameters

NameTypeDescription
rhsComparecompare object

Return

TypeDescription
Int0 if equal, -1 if right-hand side i greater, 1 if left-hand side is greater

CompareIgnoreCase #

Compares two strings, ignoring case

method : public : CompareIgnoreCase(rhs:String) ~ Int

Parameters

NameTypeDescription
rhsStringstring to compare

Return

TypeDescription
Int0 if equal, -1 if right-hand side is greater, 1 if left-hand side is greater

Compress #

Compresses a string removing unused space.

method : public : Compress() ~ Nil

Contains #

Checks if string contains a substring

method : public : Contains(find:String) ~ Bool

Parameters

NameTypeDescription
findStringstring to search for

Return

TypeDescription
Booltrue if found, false otherwise

Example

if("Hello World"->Contains("World")) {
  "Found"->PrintLine();
};

ContainsIgnoreCase #

Checks if string contains a substring, ignoring case

method : public : ContainsIgnoreCase(find:String) ~ Bool

Parameters

NameTypeDescription
findStringstring to search for

Return

TypeDescription
Booltrue if found, false otherwise

Copy #

Creates a new instance of the string

method : public : Copy() ~ String

Return

TypeDescription
Stringnew string instance

Count #

Counts the occurrence of a character

method : public : Count(char:Char) ~ Int

Parameters

NameTypeDescription
charCharcharacter to search for

Return

TypeDescription
Intcount of occurrences or -1 if not found

Count # native

Counts the occurrence of a character

method : public : native : Count(offset:Int, char:Char) ~ Int

Parameters

NameTypeDescription
offsetIntsearch offset
charCharcharacter to search for

Return

TypeDescription
Intcount of occurrences or -1 if not found

Count #

Counts occurrences of a substring

method : public : Count(find:String) ~ Int

Parameters

NameTypeDescription
findStringstring to count

Return

TypeDescription
Intnumber of occurrences found

Delete #

Deletes the character at the given index

method : public : Delete(offset:Int) ~ Bool

Parameters

NameTypeDescription
offsetIntoffset index

Return

TypeDescription
Booltrue if deleted, false otherwise

Delete #

Deletes the characters at the given range

method : public : Delete(offset:Int, length:Int) ~ Bool

Parameters

NameTypeDescription
offsetIntoffset index
lengthIntlength

Return

TypeDescription
Booltrue if deleted, false otherwise

EndsWith #

Checks if the string ends with the given character

method : public : EndsWith(char:Char) ~ Bool

Parameters

NameTypeDescription
charCharcharacter to compare

Return

TypeDescription
Booltrue if ends with character, false otherwise

Example

if("report.pdf"->EndsWith('f')) {
  "Ends with f"->PrintLine();
};

EndsWith # native

Checks if the string ends with the given string

method : public : native : EndsWith(string:String) ~ Bool

Parameters

NameTypeDescription
stringStringstring to check for

Return

TypeDescription
Booltrue if ends with string, false otherwise

Example

file := "report.pdf";
if(file->EndsWith(".pdf")) {
  "PDF file"->PrintLine();
};

EndsWithIgnoreCase #

Checks if the string ends with the given string, ignoring case

method : public : EndsWithIgnoreCase(string:String) ~ Bool

Parameters

NameTypeDescription
stringStringstring to check for

Return

TypeDescription
Booltrue if ends with string, false otherwise

Equals # native

Compares two strings

method : public : native : Equals(rhs:String) ~ Bool

Parameters

NameTypeDescription
rhsStringstring to compare

Return

TypeDescription
Booltrue if equal, false otherwise

Example

if("hello"->Equals("hello")) {
  "Match"->PrintLine();
};

Equals #

Compares a string to an array of values

method : public : Equals(rhs:String[]) ~ Bool

Parameters

NameTypeDescription
rhsStringarray of values to compare

Return

TypeDescription
Booltrue if at least one match, false otherwise

EqualsIgnoreCase # native

Compares two strings, ignoring the case

method : public : native : EqualsIgnoreCase(rhs:String) ~ Bool

Parameters

NameTypeDescription
rhsStringstring to compare

Return

TypeDescription
Booltrue if equal, false otherwise

EqualsIgnoreCase #

Compares a string to an array of values, ignoring case

method : public : EqualsIgnoreCase(rhs:String[]) ~ Bool

Parameters

NameTypeDescription
rhsStringarray of values to compare

Return

TypeDescription
Booltrue 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

NameTypeDescription
charCharcharacter to search for

Return

TypeDescription
Intindex of first occurrence, -1 otherwise

Example

pos := "Hello"->Find('l');
pos->PrintLine();  # 2

Find # native

Searches for the first occurrence of a character

method : public : native : Find(offset:Int, char:Char) ~ Int

Parameters

NameTypeDescription
offsetIntsearch offset
charCharcharacter to search for

Return

TypeDescription
Intindex of first occurrence, -1 otherwise

Find #

Searches for the first occurrence of a string

method : public : Find(find:String) ~ Int

Parameters

NameTypeDescription
findStringstring to search for

Return

TypeDescription
Intindex of first occurrence, -1 otherwise

Example

pos := "Hello World"->Find("World");
"Found at: {$pos}"->PrintLine();  # Found at: 6

Find # native

Searches for the first occurrence of a string

method : public : native : Find(offset:Int, find:String) ~ Int

Parameters

NameTypeDescription
offsetIntsearch index offset
findStringstring to search for

Return

TypeDescription
Intindex of first occurrence, -1 otherwise

FindAll #

Searches for all occurrences of a string

method : public : FindAll(find:String) ~ Int[]

Parameters

NameTypeDescription
findStringstring to search for

Return

TypeDescription
Intan array of indexes

FindLast #

Searches for the last occurrence of a character

method : public : FindLast(char:Char) ~ Int

Parameters

NameTypeDescription
charCharcharacter to search for

Return

TypeDescription
Intindex of last occurrence, -1 otherwise

FindLast # native

Searches for the last occurrence of a character

method : public : native : FindLast(offset:Int, char:Char) ~ Int

Parameters

NameTypeDescription
offsetIntsearch offset
charCharcharacter to search for

Return

TypeDescription
Intindex of last occurrence, -1 otherwise

FindLast #

Searches for the last occurrence of a string

method : public : FindLast(str:String) ~ Int

Parameters

NameTypeDescription
strStringstring to search for

Return

TypeDescription
Intindex of last occurrence, -1 otherwise

First #

Returns the first character

method : public : First() ~ Char

Return

TypeDescription
Charfirst character

Get # native

Returns character at the given index

method : public : native : Get(index:Int) ~ Char

Parameters

NameTypeDescription
indexIntindex offset

Return

TypeDescription
Charcharacter at index

Example

ch := "Hello"->Get(1);
ch->PrintLine();  # e

Has #

Searches for the first occurrence of a character

method : public : Has(char:Char) ~ Bool

Parameters

NameTypeDescription
charCharcharacter to search for

Return

TypeDescription
Booltrue of found, false otherwise

Has #

Searches for the first occurrence of a character

method : public : Has(offset:Int, char:Char) ~ Bool

Parameters

NameTypeDescription
offsetIntsearch offset
charCharcharacter to search for

Return

TypeDescription
Booltrue of found, false otherwise

Has #

Searches for the first occurrence of a character

method : public : Has(str:String) ~ Bool

Parameters

NameTypeDescription
strStringstring to search for

Return

TypeDescription
Booltrue of found, false otherwise

Has #

Searches for the first occurrence of a character

method : public : Has(offset:Int, str:String) ~ Bool

Parameters

NameTypeDescription
offsetIntsearch offset
strStringstring to search for

Return

TypeDescription
Booltrue of found, false otherwise

HashID #

Returns a unique hash ID for a given string sequence

method : public : HashID() ~ Int

Return

TypeDescription
Inthash ID

Insert #

Insert inserts a character

method : public : Insert(index:Int, char:Char) ~ Bool

Parameters

NameTypeDescription
indexIntinsert offset
charCharcharacter to insert

Return

TypeDescription
Booltrue if inserted, false otherwise

Insert #

Insert inserts a string

method : public : Insert(index:Int, string:String) ~ Bool

Parameters

NameTypeDescription
indexIntinsert offset
stringStringstring to insert

Return

TypeDescription
Booltrue if inserted, false otherwise

Insert #

Insert inserts a string

method : public : Insert(index:Int, buffer:Char[]) ~ Bool

Parameters

NameTypeDescription
indexIntinsert offset
bufferCharbuffer to insert

Return

TypeDescription
Booltrue if inserted, false otherwise

IsAlpha #

Checks if string contains only alphabetic characters (a-z, A-Z)

method : public : IsAlpha() ~ Bool

Return

TypeDescription
Booltrue if all characters are alphabetic, false otherwise

IsAlphaNumeric #

Checks if string contains only alphanumeric characters (a-z, A-Z, 0-9)

method : public : IsAlphaNumeric() ~ Bool

Return

TypeDescription
Booltrue if all characters are alphanumeric, false otherwise

IsBlank #

Checks if the string is empty or contains only whitespace

method : public : IsBlank() ~ Bool

Return

TypeDescription
Booltrue if blank, false otherwise

IsEmpty #

Returns rather the string is empty

method : public : IsEmpty() ~ Bool

Return

TypeDescription
Booltrue if empty, false otherwise

Example

str := "";
if(str->IsEmpty()) {
  "Empty string"->PrintLine();
};

IsFloat #

Checks to see if the string can be represented as an float

method : public : IsFloat() ~ Bool

Return

TypeDescription
Booltrue if the string can be represented as an float, false otherwise

IsInt # native

Checks to see if the string can be represented as an interger

method : public : native : IsInt() ~ Bool

Return

TypeDescription
Booltrue if the string can be represented as an interger, false otherwise

IsNumeric #

Checks if string contains only numeric characters (0-9)

method : public : IsNumeric() ~ Bool

Return

TypeDescription
Booltrue if all characters are numeric, false otherwise

Join # function

Joins an array of strings with a separator

function : Join(parts:String[], sep:String) ~ String

Parameters

NameTypeDescription
partsStringarray of strings to join
sepStringseparator string

Return

TypeDescription
Stringjoined string

Justify #

Justify if word length is then width

method : public : Justify(width:Int, is_left:Bool) ~ String

Parameters

NameTypeDescription
widthIntwidth to justify to
is_leftBoolif true, justify left, right otherwise

Return

TypeDescription
Stringpadded string

Last # native

Returns the last character

method : public : native : Last() ~ Char

Return

TypeDescription
Charlast character

Lines # native

Splits a string into lines

method : public : native : Lines() ~ String[]

Return

TypeDescription
Stringarray of lines

New # constructor

Default constructor

New()

New # constructor

Copy constructor

New(string:String)

Parameters

NameTypeDescription
stringStringstring to be copied

New # constructor

Copy constructor

New(array:Char[])

Parameters

NameTypeDescription
arrayChararray to be copied

New # constructor

Constructor with initial capacity

New(capacity:Int)

Parameters

NameTypeDescription
capacityIntinitial buffer capacity

New # constructor

Copy constructor

New(array:Char[], copy:Bool)

Parameters

NameTypeDescription
arrayChararray to be copied
copyBoolif false, use array for value for string otherwise copy values

New # constructor

Copy constructor

New(array:Char[], offset:Int, length:Int)

Parameters

NameTypeDescription
arrayChararray to be copied
offsetIntoffset array index offset
lengthIntnumber of characters to copy

New # constructor

Copy constructor

New(bytes:Byte[])

Parameters

NameTypeDescription
bytesBytearray to be copied

New # constructor

Copy constructor

New(bytes:Byte[], offset:Int, length:Int)

Parameters

NameTypeDescription
bytesBytearray to be copied
offsetIntoffset array index offset
lengthIntnumber of characters to copy

Pad #

Pads a string with a character

method : public : Pad(char:Char, num:Int, is_left:Bool) ~ String

Parameters

NameTypeDescription
charCharcharacter to pad with
numIntnumber of character to pad
is_leftBoolif true, pad left, otherwise pad right

Return

TypeDescription
Stringpadded string

Pop # native

Pops the last character from the string reducing the size by 1

method : public : native : Pop() ~ Char

Return

TypeDescription
Charlast character of the string

Print #

Print a string

method : public : Print() ~ Nil

PrintLine # function

Prints values

function : PrintLine(v:String[]) ~ Nil

Parameters

NameTypeDescription
vStringvalues to print

PrintLine #

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

NameTypeDescription
findStringstring to search for

Return

TypeDescription
Stringnew string instance

Remove #

Removes the first occurrence of a character from a string

method : public : Remove(char:Char) ~ String

Parameters

NameTypeDescription
charCharcharacter to remove

Return

TypeDescription
Stringstring with first matching character removed

RemoveAll #

Removes all occurrences the search string

method : public : RemoveAll(find:String) ~ String

Parameters

NameTypeDescription
findStringstring to search for

Return

TypeDescription
Stringnew string instance

RemoveAll #

Removes all occurrences the search character

method : public : RemoveAll(find:Char) ~ String

Parameters

NameTypeDescription
findCharcharacter to search for

Return

TypeDescription
Stringnew string instance

Repeat #

Returns a string repeated n times

method : public : Repeat(n:Int) ~ String

Parameters

NameTypeDescription
nIntnumber of repetitions

Return

TypeDescription
Stringrepeated string

Replace #

Replaces the first occurrence the search string

method : public : Replace(find:String, replace:String) ~ String

Parameters

NameTypeDescription
findStringstring to search for
replaceStringstring to replace with

Return

TypeDescription
Stringnew string instance

Example

result := "aabbcc"->Replace("bb", "XX");
result->PrintLine();  # aaXXcc

ReplaceAll #

Replaces all occurrences the search string

method : public : ReplaceAll(find:String, replace:String) ~ String

Parameters

NameTypeDescription
findStringstring to search for
replaceStringstring to replace with

Return

TypeDescription
Stringnew string instance

Example

result := "cat and cat"->ReplaceAll("cat", "dog");
result->PrintLine();  # dog and dog

ReplaceAll # native

Replaces all occurrences the search string

method : public : native : ReplaceAll(find:Char, replace:Char) ~ String

Parameters

NameTypeDescription
findCharcharacter to search for
replaceCharcharacter to replace with

Return

TypeDescription
Stringnew string instance

Reverse # native

Reverses a string

method : public : native : Reverse() ~ String

Return

TypeDescription
Stringreversed string

Example

"Hello"->Reverse()->PrintLine();  # olleH

Set #

Sets character at the given index

method : public : Set(char:Char, index:Int) ~ Bool

Parameters

NameTypeDescription
charCharcharter to set
indexIntindex offset

Return

TypeDescription
Booltrue if successful, false otherwise

SetFloatFormat # function

Set floating point string format.

function : SetFloatFormat(format:Number->Format) ~ Nil

Parameters

NameTypeDescription
formatNumber->Formatfloat format

SetFloatPrecision # function

Set floating point string precision.

function : SetFloatPrecision(precision:Int) ~ Nil

Parameters

NameTypeDescription
precisionIntdecimal precision

SetIntFormat # function

Set integer string format.

function : SetIntFormat(format:Number->Format) ~ Nil

Parameters

NameTypeDescription
formatNumber->Formatinteger format

Size #

Return the size of the string

method : public : Size() ~ Int

Return

TypeDescription
Intsize of the string

Example

"Hello"->Size()->PrintLine();  # 5

Split #

Splits a string based upon delimiter

method : public : Split(delim:String) ~ String[]

Parameters

NameTypeDescription
delimStringsplitting delimiter

Return

TypeDescription
Stringarray of split sub strings

Example

parts := "one,two,three"->Split(",");
each(part in parts) {
  part->PrintLine();
};

Split #

Splits a string based upon delimiter

method : public : Split(delim:Char) ~ String[]

Parameters

NameTypeDescription
delimCharsplitting delimiter

Return

TypeDescription
Stringarray of split sub strings

Example

parts := "a:b:c"->Split(':');
parts->Size()->PrintLine();  # 3

StartsWith #

Checks if the string starts with the given character

method : public : StartsWith(char:Char) ~ Bool

Parameters

NameTypeDescription
charCharcharacter to compare

Return

TypeDescription
Booltrue if starts with character, false otherwise

Example

if("https://example.com"->StartsWith('h')) {
  "Starts with h"->PrintLine();
};

StartsWith #

Checks if the string starts with the given string

method : public : StartsWith(string:String) ~ Bool

Parameters

NameTypeDescription
stringStringstring to check for

Return

TypeDescription
Booltrue if starts with string, false otherwise

Example

url := "https://example.com";
if(url->StartsWith("https://")) {
  "Secure"->PrintLine();
};

StartsWithIgnoreCase #

Checks if the string starts with the given string, ignoring case

method : public : StartsWithIgnoreCase(string:String) ~ Bool

Parameters

NameTypeDescription
stringStringstring to check for

Return

TypeDescription
Booltrue if starts with string, false otherwise

SubString #

Creates a sub-string

method : public : SubString(length:Int) ~ String

Parameters

NameTypeDescription
lengthIntmax length of sub-string

Return

TypeDescription
Stringsub-string

Example

tail := "Hello World"->SubString(5);
tail->PrintLine();  # Hello

SubString #

Creates a sub-string

method : public : SubString(offset:Int, length:Int) ~ String

Parameters

NameTypeDescription
offsetIntindex offset
lengthIntmax length of sub-string

Return

TypeDescription
Stringsub-string

Example

sub := "Hello World"->SubString(6, 5);
sub->PrintLine();  # World

ToBool #

Parses the string into a boolean

method : public : ToBool() ~ Bool

Return

TypeDescription
Boolboolean value

ToByteArray # native

Returns a byte array representation of the String

method : public : native : ToByteArray() ~ Byte[]

Return

TypeDescription
Bytebyte array

ToCharArray #

Returns a character array representation of the String

method : public : ToCharArray() ~ Char[]

Return

TypeDescription
Charcharacter array

ToFloat #

Parses the string into a float

method : public : ToFloat() ~ Float

Return

TypeDescription
Floatfloat value

Example

f := "3.14"->ToFloat();
(f * 2.0)->PrintLine();  # 6.28

ToInt #

Parses the string into an integer

method : public : ToInt() ~ Int

Return

TypeDescription
Intinteger value

Example

n := "42"->ToInt();
(n * 2)->PrintLine();  # 84

ToInt #

Parses the string into an integer

method : public : ToInt(base:Int) ~ Int

Parameters

NameTypeDescription
baseIntbase radix

Return

TypeDescription
Intinteger value

ToLower # native

Transforms a to lower case

method : public : native : ToLower() ~ String

Return

TypeDescription
Stringlower case string

Example

"WORLD"->ToLower()->PrintLine();  # world

ToString #

Returns string of self

method : public : ToString() ~ String

Return

TypeDescription
Stringstring of self

ToString # native

Formats an array of string

function : native : ToString(v:String[]) ~ String

Parameters

NameTypeDescription
vStringstring array

ToUpper # native

Transforms a to upper case

method : public : native : ToUpper() ~ String

Return

TypeDescription
Stringupper case string

Example

"hello"->ToUpper()->PrintLine();  # HELLO

Trim # native

Removes all leading and trailing white space

method : public : native : Trim() ~ String

Return

TypeDescription
Stringtrimmed string

Example

cleaned := "  hello world  "->Trim();
cleaned->PrintLine();  # hello world

TrimBack # native

Removes all trailing white space

method : public : native : TrimBack() ~ String

Return

TypeDescription
Stringtrimmed string

TrimChars #

Removes all leading and trailing occurrences of characters in the given set

method : public : TrimChars(chars:String) ~ String

Parameters

NameTypeDescription
charsStringstring of characters to trim

Return

TypeDescription
Stringtrimmed string

TrimFront # native

Removes all leading white space

method : public : native : TrimFront() ~ String

Return

TypeDescription
Stringtrimmed string

Truncate #

Truncates the string to at most max characters, appending suffix if cut

method : public : Truncate(max:Int) ~ String

Parameters

NameTypeDescription
maxIntmaximum length of result

Return

TypeDescription
Stringtruncated string

Truncate #

Truncates the string to at most max characters, appending suffix if cut

method : public : Truncate(max:Int, suffix:String) ~ String

Parameters

NameTypeDescription
maxIntmaximum length of result
suffixStringsuffix to append when truncated

Return

TypeDescription
Stringtruncated string