substr

substr <string> <start> <len>

Extract a substring of up to len characters, starting at a 0-based offset.

Arguments

Returns

A string — the copied characters. The source is never modified.

Examples

after command (say) {
  do "say [substr "hello world" 0 5]"
}

This copies five characters from offset 0, so the mob says hello.

after command (say) {
  do "say [substr "hello world" 6 100]"
}

The length runs past the end of the string, so it clamps: the mob says world (everything from offset 6 onward).

See also