Skip to content

Substring

String Substring(String input, Int startIndex, Int endIndex = -1)

System · system operation · implicitly imported

Returns the substring of a String between a start index and an end index.

An endIndex of -1 means "until the end of the String".

Parameters

  • String input — The String to take the substring of.
  • Int startIndex — The start index of the substring (inclusive).
  • Int endIndex = -1 — The end index of the substring (exclusive), or -1 for the end of the String.

Returns

String — The substring from startIndex until endIndex.

Errors

A runtime type error if input is not a String, or an index is not an Int.

Examples

String s = Substring("Hello World", 6);

See Also