Substring

This function can be used to get a substring of a string.

Syntax

string substring(string $text, integer $startIndex, integer $substringLength)

Gets the substring of $text.
The substring starts at $startIndex and will take up to $substringLength next characters or until the end of $text.
If $text is null the function will return null. If $startIndex is greater than the length of $text the function will return an empty string.

Parameters

$text: The string to split.
$startIndex: The zero index position in $text to start the substring from.
$substringLength: The length of the substring i.e. number of characters to include

Example

Data
{ "String": "Lorem Ipsum Dolor" }
Transformation
{ "NewString": substring(String, `0`, `5`) }
Output
{ "NewString": "Lorem" }

In this example the string value “String” has the substring extracted from the first 5 characters “Lorem”.