String Functions

string.indexOf

Int32 string.indexOf(String string, String substring, Int32 fromPosition)

Finds the index of the first occurrence of the substring within the input string, starting the search at a given start index. Gives a runtime error if the start or the end position is outside of its valid range.

Parameters:

  • string - the input string (non-nullable).
  • substring - the substring to be searched (non-nullable).
  • fromPosition - the start position of the search (inclusive, in the range [-size,size]). A negative value indicates a position relative to the end of the string (non-nullable).

Returns:

the index of the substring, or -1 if not found.

string.join

<Primitive T> String string.join(List(T) values, String delimiter)

Returns a string that is the result of joining the string representations of the input list elements with the specified delimiter.

Parameters:

  • values - the input list (non-nullable, null elements not allowed).
  • delimiter - the string to be used as a delimiter (non-nullable).

Returns:

the joined string.

string.length

Int32 string.length(String string)

Returns the length of the input string.

Parameters:

  • string - the input string (non-nullable).

Returns:

the length of the input string.

string.regexMatch

List(String) string.regexMatch(String string, String regex)

Finds all non-overlapping substrings of the input string that match the regular expression (regex).

Parameters:

  • string - the input string (non-nullable).
  • regex - the regex to be searched (non-nullable).

Returns:

the list of matching substrings.

string.split

List(String) string.split(String string, String separator)

Splits the list of substrings of the input string resulting from splitting it via the separator.

Parameters:

  • string - the input string (non-nullable).
  • separator - the separator string (non-nullable).

Returns:

the substrings.

string.startsWith

Bool string.startsWith(String input, String prefix)

Checks whether a string starts with a specified prefix.

Parameters:

  • input - the string to check (non-nullable).
  • prefix - the prefix (non-nullable).

Returns:

true if the string starts with the specified prefix, false otherwise.

string.substring

String string.substring(String string, Int32 startPosition, Int32 endPosition)

Creates a substring from the input string. Gives a runtime error if the start or the end position is outside of its valid range.

Parameters:

  • string - the input string (non-nullable).
  • startPosition - the start position of the substring (inclusive, in the range [-size,size]). A negative value indicates a position relative to the end of the string (non-nullable).
  • endPosition - the end position of the substring (exclusive, in the range [-size,size]). A negative value indicates a position relative to the end of the string (non-nullable).

Returns:

the substring.

string.toLowerCase

String string.toLowerCase(String string)

Returns the lowercase representation of the string.

Parameters:

  • string - the input string (non-nullable).

Returns:

the input string converted to lowercase.

string.toUpperCase

String string.toUpperCase(String string)

Returns the uppercase representation of the string.

Parameters:

  • string - the input string (non-nullable).

Returns:

the input string converted to uppercase.