Strings

The core string type is extended with a variety of methods which can be invoked on string objects. For example,

  public string x;
  formula x_x = (x + x).reverse();

Methods

MethodDescriptionResult type
length()Returns the length of a stringint
split(string word)Splits the string into a list of parts seperated by the given wordlist<string>
split(maybe<string> word)Splits the string into a list of parts seperated by the given word if the word is availablemaybe<list<string>>
contains(string word)Tests if the string contains the given wordbool
contains(maybe<string> word)Tests if the string contains the given word if the word is availablemaybe<bool>
indexOf(string word)Returns the position of the given wordint
indexOf(maybe<string> word)Returns the position of the given word if the word is availablemaybe<int>
indexOf(string word, int offset)Returns the position of the given word after the given offsetint
indexOf(maybe<string> word, int offset)Returns the position of the given word if the word is available after the given offsetmaybe<int>
trim()Returns a new version of the string with whitespace removed from both the head and tailstring
trimLeft()Returns a new version of the string with whitespace removed from the head/start/left-side of the stringstring
trimRight()Returns a new version of the string with whitespace removed from the tail/end/right-side of the stringstring
upper()Returns a new version of the string with all upper case charactersstring
lower()Returns a new version of the string with all lower case charactersstring
mid(int start, int length)Returns the part of the string starting at the indicated start position with the length provided.maybe<string>
left(int start)Returns the part of the string starting at the indicated start position until the end of the stringmaybe<string>
right(int length)Returns a string with the indicated length coming from the end of the stringmaybe<string>
substr(int start, int end)Returns a string that starts at the given position and ends with the given positionmaybe<string>
startsWith(string prefix)Returns whether or not string is prefixed by the given stringbool
endsWith(string prefix)Returns whether or not string is suffixed by the given stringbool
multiply(int n)Returns the concatentation of the string n timesstring
reverse()Returns a copy of the string with the characters reversedstring

Functions

FunctionDescriptionResult type
String.charOf(int ch)Returns a string with the give integer character converted into a stringstring