substring
Fetch a substring of a string from a given position with a given length
Definition
string substring(string $text, integer $startIndex, int $substringLength)
Returns the substring of $text starting at $startIndex with length $substringLength.
Parameters
string $text
Text to search select a substring of.
number $startIndex
The index of the original string where the first character of the substring is. Starts from zero.
int $substringlength
The length of the substring to be returned.
Returns
string
Substring of $text starting at $startIndex of length $substringLength.
Examples
{
a: substring('Hello, world!', `7`, `5`),
b: substring('Hello, world!', `7`, `50`),
c: substring('Hello, world!', `-7`, `5`), // Error
d: substring('Hello, world!', `0`, `0`),
e: substring('Hello, world!', `0`, `true`),
f: substring('Hello, world!', `0`, `null`), // Error
g: substring('', `0`, `10`),
h: substring('', `1`, `10`),
i: substring(`null`, `0`, `1`)
}{
"a": "world",
"b": "world!",
"d": "",
"e": "H",
"g": "",
"h": "",
"i": null
}Updated 6 months ago