substring
TABLE OF CONTENTS
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 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
Transformation
{
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`)
}Result
{
"a": "world",
"b": "world!",
"d": "",
"e": "H",
"g": "",
"h": "",
"i": null
}Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article