Report templatesFunctions
split
Split a string into an array based on a delimiter and optionally return a specific element
Usage
The split
function divides a string into an array of substrings using a specified delimiter. You can optionally retrieve a specific element from the resulting array by index.
Syntax
{input | split:delimiter:index:fallback}
Parameters
input
(string): The string to splitdelimiter
(string): The character or string to split byindex
(number, optional): Zero-based index of the element to returnfallback
(string, optional): Default value if input is empty or index is out of bounds (defaults to "N/A")
Returns
- If
index
is provided: Returns the element at the specified index or the fallback value - If
index
is not provided: Returns the entire array of split elements
Examples
Basic splitting
{"apple,banana,orange" | split:","}
// Returns: ["apple", "banana", "orange"]
Get specific element by index
{"apple,banana,orange" | split:",":1}
// Returns: "banana"
Using with fallback
{"apple,banana" | split:",":5:"Not found"}
// Returns: "Not found"
Splitting project names
{project.name | split:"-":2:"N/A"}
// Returns: The third segment of a hyphen-separated project name, or "N/A" if not found
Splitting IP addresses
{"192.168.1.1" | split:".":0}
// Returns: "192"
Splitting file paths
{file.path | split:"/":3:"Unknown"}
// Returns: The fourth segment of the path, or "Unknown" if not found