# Substring

TIP

  • substring(<string>, <start>, [length])
  • You can use this function to extract a part from a string, the <start> parameter defines the beginning of the string to start from, and 0 being the first letter, you can change the value of <start> or <length> to a negative number to start counting from the end of the string.
  • If you only pass the <start> parameter without [length] then the length will be to the end of the string.

# Parameters

  • <string> The text to search in as string
  • <start> The character position to start count from as int
  • [length] The amount of characters to skip as int

# Example

1: $text$ = 'Hello world, I am Steve'
2: $name$ = substring($text$, -5)
3: sendMessage($player$, $name$)
4: $extract$ = substring($text$, 6, 11)
5: sendMessage($player$, $extract$)

# Output

$name$     ->  "Steve"
$extract$  ->  "world, I am"
ON THIS PAGE